Vi and ViM Tips

Keyboard Shortcuts

Move / delete a block of text

  • Shift-v – Visual select lines of text
  • Press ‘d’ to delete the text
  • Press ‘p’ to paste text at current cursor position

Add this to .vimrc to return cursor to last position when opening files:

if has("autocmd")
 	au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

Themes / Color schemes can be found in ~/.vim/colors

syntax on
color dracula

Relative Line Numbers

Vim has a neat feature (since 7.3), relative line numbers, this feature is useful when you want to yank / delete / move lines that you know are relative to the current cursor position.

set relativenumber
No comments
Comments are closed.