Categories

Tags

The following is setting up for my vim.

Plugin

CurtineIncSw.vim

Toggle between .c and .h buffers.

map <C-h> :call CurtineIncSw()<CR>

fzf.vim

  • ctrl-t: open in a new tab
  • ctrl-x: a new split
  • ctrl-v: a new vertical split

vim-markdown

  • zr: reduces fold level throughout the buffer
  • zR: opens all folds
  • zm: increases fold level throughout the buffer
  • zM: folds everything all the way
  • za: open a fold your cursor is on
  • zA: open a fold your cursor is on recursively
  • zc: close a fold your cursor is on
  • zC: close a fold your cursor is on recursively

python-mode

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zc close a fold at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
  • zr decreases the foldlevel by one.
  • zR decreases the foldlevel to zero – all folds will be open.
  • zd deletes the fold at the cursor.
  • zE deletes all folds.
  • [z move to start of open fold.
  • ]z move to end of open fold.

rtags

  • install: brew install rtags
  • start up: brew services start rtags
  • Start the RTags daemon: rdm&
  • Index the RTags project: rc -J .

Commonly used command

show variable type

  • [i: display the definition of a variable
  • [d: display a macro definition
  • [I: display all the lines containing the variable name
  • gd: go to definition of local variable (first occurrence of keyword in current function).
  • gD: go to definition of global variable (first occurrence of keyword in current file).

change window split size

  • ctrl+w +/- : increase/decrease height (ex. 20+)
  • ctrl+w >/<: increase/decrease width(ex. 30<C-w><)
  • ctrl+w _ : set height (ex. 50<C_w>_)
  • ctrl+w | : set width
  • ctrl+w = : equalize width and height of all windows

    add same word for multi lines

  • step 1:Ctrl+v
  • step 2: I
  • step 3: write the words you want to add
  • step 4: ESC

tagbar for golang

  • Install gotags
    go get -u github.com/jstemmer/gotags
    
  • Add the following to ~/.vimrc
    let g:tagbar_type_go = {
      \ 'ctagstype' : 'go',
      \ 'kinds'     : [
          \ 'p:package',
          \ 'i:imports:1',
          \ 'c:constants',
          \ 'v:variables',
          \ 't:types',
          \ 'n:interfaces',
          \ 'w:fields',
          \ 'e:embedded',
          \ 'm:methods',
          \ 'r:constructor',
          \ 'f:functions'
      \ ],
      \ 'sro' : '.',
      \ 'kind2scope' : {
          \ 't' : 'ctype',
          \ 'n' : 'ntype'
      \ },
      \ 'scope2kind' : {
          \ 'ctype' : 't',
          \ 'ntype' : 'n'
      \ },
      \ 'ctagsbin'  : 'gotags',
      \ 'ctagsargs' : '-sort -silent'
    \ }
    

ctags for golang

Add the following to ~/.ctags

--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/`