Tip: #876 - Selecting blocks of paragraphs
Created: February 15, 2005 18:48 Complexity: basic Author: Dane Summers Version: 6.0 Karma: 13/8 Imported from: Tip#876
I use vim in windows a lot and have to copy text from vim into some other window. I found myself copying SQL queries a lot and figured I should save my poor fingers so many keypresses. To that end I came up with two handy mappings. The first one just selects the entire text of the paragraph that your cursor is currently within, using Control-Shift-v. The second takes it one step further, by yanking the entire paragraph your cursor is in into the * buffer (windows clipboard) all while keeping your cursor on the same line.
one:
- map <C-S-v> (V)
two:
- map <C-S-v> (V)*y
Comments
Is there a shortcut for selecting the entire paragraph in unix? ctrl-shift-v does something weird with the current copy buffer contents.
Anonymous , February 16, 2005 3:16
To select a paragraph just press following: vip. Or: vap. There is aloso a lot of usable things you may select. Word: viw, block in braces or in curly braces: vib and viB.
Ivan Tishchenko , February 16, 2005 3:36
I love this tip, never knew I could select so much with vip, viw, after years of being a vim fan. Good work guys.
Sunita Indorian , February 16, 2005 12:08
To know more about viw - :help v_iw
v_iw means vstands for visual and iw is the command in the visual mode.
Similarly if you want to know anything related to command line use
- help c_<whateveryouwant>
For insert mode -
- help i_<whateveryouwant>
shankar--AT--txc.stpn.soft.net , February 26, 2005 7:25
Update -
First of all thanks to Ivan for pointing out the 'vip' command.
I found that my handy script I mentioned to you all wasn't as great as I'd thought. I didn't pick a very good mapping, because <C-S-v> overwrites the usual command mode 'S-v' (line visual select) command, which I use A LOT!
Dang it.
I've ended up using:
let mapleader=";" map <Leader><C-v> "*p imap <Leader><C-v> �* map <Leader><C-c> "*y map <Leader>yy "*yy
Using the leader command keeps me from messing up the standard 'C-v' functionality. I changed my mapleader to ';' because I'm a dvorak user and the ';' is in a convenient location. You may already use, or want to use, a different one.
dsummersl--AT--yahoo.com , April 28, 2005 10:01