Wikia

Vim Tips Wiki

Changes: Quickly insert a single word

Edit

Back to page

(Remove html character entities)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=347
 
|previous=347
 
|next=349
 
|next=349
|created=October 19, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=spudnic
 
|author=spudnic
Line 34: Line 34:
   
 
----
 
----
I get a lot of mileage out of <tt>cw</tt> which is change word and <tt>dw</tt> which is delete word.
+
I get a lot of mileage out of <code>cw</code> which is change word and <code>dw</code> which is delete word.
   
 
Try them out!
 
Try them out!

Latest revision as of 05:25, July 13, 2012

Tip 348 Printable Monobook Previous Next

created 2002 · complexity basic · author spudnic · version 5.7


These two mappings make it quick and easy to insert a word.

nmap <buffer> <silent> ,w :exec ":imap \<space\> \<space\>\<esc\>,BB"<CR>i
nmap <buffer> <silent> ,BB :exec ":iunmap \<space\>"<CR>

Given the sentence:

The quick fox.

To add the word "brown" you would put your cursor on the f in fox and type ",w" (or whatever you decide is a good mapping). Type the word brown. As soon as you hit space you are out of insert mode.

CommentsEdit

Unless I missed something, this doesn't save any keystrokes. Without this, I would use two keystrokes "i" to enter insert mode and ESC to exit. Here I still would still need two keystokes "," and "w".


Size isn't everything! This seems easier. Finding the ESC is harder than , . and with this you're entering ,w together rather than a key before your word and another key at the end. So you start this with 2 characters, but it ends itself automatically, which seems easier and more fluid to me.


I get a lot of mileage out of cw which is change word and dw which is delete word.

Try them out!


Around Wikia's network

Random Wiki