History Report a problem
Article Edit this page Discussion

Mappings and commands for visual mode

From Vim Tips Wiki

(Redirected from VimTip1011)
Jump to: navigation, search
 

Tip 1011Previous TipNext Tip

Created: October 6, 2005 Complexity: basic Author: Jean-Christophe Clavier Minimum version: 5.7 Karma: 0/2 Imported from: Tip#1011


For those who use visual mode, here are some commands and mappings that may be useful:

First of all gv reselects the previous visual area.

Prepare a :command on the previous visual selected area ('<,'> is slow to type):

map <M-:> :'<,'>

Copy the word under cursor in the clipboard:

nnoremap <F4> "+yiw

Copy the visual selected area in the clipboard:

vnoremap <F4> "+y

Replace the word under cursor with the content of the clipboard:

nnoremap <F5> viw"+p

Replace the visual selected area with the content of the clipboard:

vnoremap <F5> "+p

Prepare the :command to replace the word under cursor:

nnoremap <S-F4> "+yiw:%s/\<<C-r>+\>/<C-r>+/gc<LEFT><LEFT><LEFT>

Prepare the :command to replace the selected area:

vnoremap <S-F4> "+y:%s/\<<C-r>+\>/<C-r>+/gc<LEFT><LEFT><LEFT>

I use the clipboard but you can use whatever register you want.

This puts "" around the word under cursor:

nnoremap <M-"> ciw"<C-r>+"<esc>

This puts "" around the visual selected area:

vnoremap <M-"> c"<C-r>+"<esc>

[edit] Comments

One key <F7> does everything. Good for inter-window copying and pasting.

"copy
vmap <F7> "+ygv"zy`>
"paste (Shift-F7 to paste after normal cursor, Ctrl-F7 to paste over visual selection)
nmap <F7> "zgP
nmap <S-F7> "zgp
imap <F7> <C-r><C-o>z
vmap <C-F7> "zp`]
cmap <F7> <C-r><C-o>z

"copy register
autocmd FocusGained * let @z=@+

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Terminator Wiki
Legend of Zelda Wiki
Flash Gordon
Everquest II Wiki
Yo-Yo Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for featured Wikia!

Send this article to a friend
"Mappings and commands for visual mode"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation