Hi,
Anyone knows how to quickly find the next occurrence of a character (like the f command) but multi-line? I.e. to quickly jump to the next occurrence of some character in a file?
Thanks!
Yaniv
Hi,
Anyone knows how to quickly find the next occurrence of a character (like the f command) but multi-line? I.e. to quickly jump to the next occurrence of some character in a file?
Thanks!
Yaniv
Isn't that what "/" does?
If you're looking for the next "x" then do /x while in command mode.
Then you can hit "n" to advance to the next x, and then the next x, etc.
There are lots of vim cheat sheets out there with all kinds of tips.
There's an example of redefining f
to ignore case in the 'eval.txt' help file.
:h eval.txt
(search for "ignore case" a couple times)
We can modify that to do what you want. Add the following function to your ~/.vimrc
file or better yet, create a plugin file: ~/.vim/plugin/find-char.vim
(create the directories if you do not already have them).
function FindChar()
let c = nr2char( getchar() )
let match = search('\V' . c)
endfunction
Then, in your ~/.vimrc
add the following line:
nmap f :call FindChar()<CR>
Now, f
should work like you want it to.
BTW, this was tested with Vim 7.2 on Ubuntu 10.04.
You could make a mapping to go to the next character under the cursor:
:map f yl/\V<c-r>"<c-m>
the \V will make sure symbols are matched literally.
Also, you may want to look at the *
and #
commands, which are already defined for you, although they might not be what you want.