How do I specify “the word under the cursor” on VIM's commandline?

Cword is the word under the cursor (:help cword ) Sorry, I should have been more complete in this answer You can nmap a command to it, or this series of keystrokes for the lazy will work: be #go to beginning of current word yw #yank to register Then, when you are typing in your pattern you can hit control-r>0w :s/\(=expand("")\) Which will map hitting '\' and 'w' at the same time to replace your command line with :s/\(\).

Is the word under the cursor (:help ). Sorry, I should have been more complete in this answer. You can nmap a command to it, or this series of keystrokes for the lazy will work: be #go to beginning of current word yw #yank to register Then, when you are typing in your pattern you can hit 0 which will paste in your command the contents of the 0-th register.

You can also make a command for this like: :nmap w :s/\(=expand("")\)/ Which will map hitting '\' and 'w' at the same time to replace your command line with :s/\(\).

CTRL-R CTRL-W search for :help c_CTRL-R for all the registers.

Another easy way to do this is to use the * command. In regular mode, when over a word, type *:s//\0\0 * makes the search pattern the current word (e.g. \). :s// does a substitution using the current search pattern, and \0 in the replacement section is the matched string.

You can then repeat this behaviour, say over word "def", by either typing the same again, or by typing *@: @: just repeats the last ex command, without a need for an , in this case the substitution. You can also record a quick macro to do this using the q command qd*:s//\0\0q Then repeat it to your hearts content by typing @d when over a word you want to double.As this is only one character less than the prior solution, it may not be worth it to you - unless you will be doing other ex-commands between the word-doubling, which would change the behaviour of.

YiwP yiw: Yank inner word (the word under the cursor). This command also moves the cursor to the beginning of the word. P: Paste before the cursor.

You can then map the e.g. : - D to this command: :nmap -D yiwP.

You need to escape the backslashes within the mapping. You can also include the substitution string within the mapping. :nmap w :s/\\(=expand("")\\)/\\1\\1.

YwPx will do what you describe. YwPxw will also advance the cursor to the next word. -- bmb.

Count word (case sensitive) nmap :%s/\(=expand("")\)//gn.

Another easy way to do this is to use the * command. * makes the search pattern the current word (e.g. Section is the matched string. @: just repeats the last ex command, without a need for an , in this case the substitution.

When over a word you want to double.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions