On Mon, May 14, 2012 at 3:48 PM, Benjamin R. Haskell <[email protected]> wrote:
> See the Eatchar function in the help for map.txt:
> :help map.txt | /Eatchar
>
> I use the following variant of Eatchar (since '\s' is the common case):
>
> fun! Eatchar(...)
>    let c = nr2char(getchar(0))
>    return c =~ (a:0 ? a:1 : '\s') ? '' : c
> endf
>
> Then, in the example Tim provided above, the iab becomes:
>
> :iab foreach
> foreach(<space>)<cr>{<cr><cr>}<up><up><up><end><left><left><C-R>=Eatchar()<CR>
>

Terrific, thank you. I cannot believe how deep this rabbit hole goes!
Every time I think "maybe VIM could be just a tad better" I discover
that it _can_ be, but I had better be prepared to read some obscure
passages of the fine manual! I would be completely lost without the
help of the wonderful people on this mailing list. Thank you for now
only showing me what needs to be done, but for showing me where to
find it in the manual. Teaching me to fish!


>> 3) The iab abbreviations will not work in the general case for remapping
>> handy things which do not end in a space, such as these:
>> inoremap ii <Esc>
>> inoremap kk <Esc>A
>> "Go back to between the last {} [] <> () "" '' or ><
>> inoremap hh
>> <c-o>?\%<c-r>=line('.')<Return>l\({}\\|\[]\\|<>\\|><\\|()\\|""\\|''\\|
>>  ><lt>\)?s+1<Return>
>> inoremap ;; <Esc>A;<Return>
>> "For adding another method argument while inside quotes
>> inoremap ,, <Right>,<Space>
>> "For adding => while inside quotes (PHP associative arrays)
>> inoremap ,,j <Right><Space>=><Space>
>>
>> In all these cases the user is stuck watching a cursor that does not move
>> according to his typing.
>>
>> I know the reasons behind not showing the text (the text might never be
>> entered into the buffer). However, the feedback of seeing the text, even if
>> it is not intended for being added to the buffer, is very important.
>
>
> Trying these mappings, I see the first letter of the mapping appear under
> the cursor (though the cursor doesn't move until the next key is typed).  Is
> it really that disconcerting?  (Typing a normal word at normal speed, it
> doesn't seem that noticeable to me.)
>

I can live with it. I just find that after a few weeks (months for
some letters like 'i') I still loose my train of thought when I see my
cursor not moving as I expect. I thought that I would get used to the
issue, but I see that I'm not. I can still function, though.


>> In any case, by far _most_ of the leading characters are used outside the
>> mappings, so it is the common case that is being made annoying for the sake
>> of the uncommon case. If need be, I would prefer that the text be added to
>> the buffer and then removed if it matches a map.
>
> I could be wrong, but I don't think mapping things that start with letters
> in insert mode is the common case.  (Though, that might be because of the
> issue we're discussing.)  My personal preference is to not map anything in
> insert mode at all, except via abbreviations.  And a lot of people seem to
> prefer <F#> keys.
>

I like to keep my fingers on the home row, this is the reason that I
started using VIM in the first place. You'll notice that the
letter-started mappings are all there to avoid using the Arrow keys or
Esc key.


>> Is there any way to accomplish this?
>
> Not as far as I know.
>

Well, we tried! Thank you Ben.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to