Friday, April 17, 2009

Pull word under cursor - vim tip

Pull word under the cursor into a command line(ex mode) or search by pressing ctrl-r ctrl-w

This is very useful for yanking long values into substitutions or into search without using the mouse.

Another way of pulling the word under cursor to search (forward,backward)

"shift *" is equivalent to /\<word under cursor\> (forward search)
"shift #" is equivalent to ?\<word under cursor\> (backward search)

1 comment:

Kuldeeps J said...

I am using "VI" editor (not vim),
i have a file with several sub-filenames in it, i want to compile the file name under cursor, can i do this in "vi" editor ?
i tried following logic;
:map #1 !compile word-under-cursor

where compile is my shell script to compile the code. how can i get word under cursor ? (in "VI" ed.)pls help.

© Jadu Saikia