Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts

9 Aug 2010

selecting text in vim from an xterm

I have line numbers turned on in vim. this makes selecting text awkward, since the line numbers are selected and copied too.

Fortunately, there is a helpful vimrc setting as long as you are using some sort of xterm:

set number
set mouse=a
Left-clicking and dragging in a terminal in which vim is running will result in text a only selection.

18 Aug 2009

vim window management

Windows are one of Vim's most convenient features, and learning some commands could prove to be useful. Some of the commands are available from the "Window" menu in gvim, or using the mouse, but using them from the keyboard is often more convenient.

To split a viewport in two, use Ctrl+W,S for a horizontal split or Ctrl+W,V for a vertical split. To move between windows use Ctrl+W followed by the arrow keys or h,j,k,l (but see this previous tip). To close a viewport use Ctrl+W,C.

Ctrl+W,r rotates the windows, and Ctrl+W, shift+R rotates them in the opposite direction. Finally, Ctrl+W,+ and Ctrl+W,- increase and decrease the height of the viewport by one line (in case you are mouse-deprived). If that's too little you can do something like 10,Ctrl+W,+ to increase the height by 10 lines.