Friday, 25 July 2014

Useful/basic key combos in Vim:

:map <F7> : tabn<CR>
:map <F8> : tabp<CR>
:set numbers
:set mouse=a
:set smartindent
:set tabstop=4
:set shiftwidth=4
:set expandtab
:e open file

:set noexpandtab    " Use tabs, not spaces
:%retab!            " Retabulate the whole file

caw: delete current word and go into insert mode
daw: delete current word
e: go to end of current word
gg <X>: goto line <X>
G <X>: goto line <X>

% select single bracket

yy to copy the line
dd to delete the line
v enter visual mode
y yunk/copy
d delete
  p paste after curren line
  P paste before current line

yiw: Yank inner word (the word under the cursor). This command also moves the cursor to the beginning of the word.
viwp: Select inner word and paste with clipboard content
b:go to beginning of current word
yw: yank word
vey: visual mode & end word & yank
vex: visual mode & end word & delete
byw: begin & yank & word

Generate tags file to OmniComplete:
ctags -R --sort=1 --languages=C,C++ --c++-kinds=+p --fields=+iasS --extra=+q

Start vim:
vim -t tags

Type in insert  mode:
<C-n> <C-p>

Navigate in Vim:

Keyboard command
Action
Ctrl-]
Jump to the tag underneath the cursor
:ts <tag> <RET>
Search for a particular tag
:tn
Go to the next definition for the last tag
:tp
Go to the previous definition for the last tag
:ts
List all of the definitions of the last tag
Ctrl-t
Jump back up in the tag stack

No comments:

Post a Comment