On Mon, Mar 12, 2012 at 22:26, Tim Chase <[email protected]> wrote:
> On 03/12/12 08:16, Dotan Cohen wrote:
>>
>> On Mon, Mar 12, 2012 at 14:18, Tim Chase<[email protected]> wrote:
>>>
>>> While an odd request, is there something I'm missing about just doing
>>>
>>> :nnoremap ii hi
>
>
> And of course, by this I mean "nnoremap ii h" :-)
>
>
>> I have no problem waiting for the limeoutlen to time out, I already
>> use that for other movements. The problem with the mapping that you
>> mention is that one must press ii for an equivalent h, so moving four
>> spaces to the left requires iiiiiiiii. I could get used to pressing
>> 4ii to move four spaces back though.
>
>
> I suppose you could make an expression mapping to a function something like
>
> function! IorH()
> let l:count=0
> let l:c=nr2char(getchar())
> while l:c == 'i'
> let l:count += 1
> let l:c=nr2char(getchar())
> endwhile
> return (l:count?(repeat('h', l:count)):'i').(l:c)
> endfunction
> nnoremap <expr> i IorH()
>
> It feels a little weird using it since it lags by one character while you're
> in this sub-mode, but it seems to do what you describe.
>
Actually, on my system (Konsole in KDE 4.7) the cursor is shown in the
command bar when running the expression, so there is no visual
feedback at all! However the expression does express some of the
things that I need to know to get the feature to work as I would like
it to.
Usually when I need to go back a few spaces I need to go between two
parentheses or two quotes. I will try to write an expression that
looks for "" '' () {} or [] on the current line, and if found will put
the cursor between the characters in insert mode.
This expression will go back to one of the character pairs:
?\({}\|[]\|()\|""\|''\)
However, is there any way to restrict it to the current line?
Everything that I search for in Google returns results relevant to
search and replace with the /g flag. Of course if it finds no matches
the cursor should remain where it is and not wind up at the beginning
or end of the line. After I get over that hump I should be able to
google my way out!
Thank you Tim. I have learned a lot from your examples. Your help is
very much appreciated!
--
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