Thursday, February 15, 2018

refx vim

VIM ref

by Gary Cheeseman gary.cheeseman.me.uk

This is my Neovim setup as at July 2017

Package management

For package management I’m using junegunn/vim-plug: Minimalist Vim Plugin Manager

Normal Mode

  • CTRL-a add [COUNT] to the number or alphabetic character
  • CTRL-x subtract [COUNT] to the number or alphabetic character

Bookmarks

I am using the kshenoy/vim-signature plugin for bookmarks

Normal mode

  • where x is a to z

  • mx Toggle mark ‘x’ and display it in the leftmost column

  • dmx Remove mark ‘x’ where x is a-zA-Z

  • m, Place the next available mark

  • m. If no mark on line, place the next available mark. Otherwise, remove (first) existing mark.

  • m- Delete all marks from the current line

  • m<Space> Delete all marks from the current buffer

  • ]` Jump to next mark

  • [` Jump to prev mark

  • ]' Jump to start of next line containing a mark

  • [' Jump to start of prev line containing a mark

  • `] Jump by alphabetical order to next mark

  • `[ Jump by alphabetical order to prev mark

  • '] Jump by alphabetical order to start of next line having a mark

  • '[ Jump by alphabetical order to start of prev line having a mark

  • m/ Open location list and display marks from current buffer`

  • m[0-9] Toggle the corresponding marker !@#$%^&*()

  • m<S-[0-9]> Remove all markers of the same type

  • ]- Jump to next line having a marker of the same type

  • [- Jump to prev line having a marker of the same type

  • ]= Jump to next line having a marker of any type

  • [= Jump to prev line having a marker of any type

  • m? Open location list and display markers from current buffer

  • m<BS> Remove all markers

Comments

normal mode

  • <leader>c space NERDComToggleComment
  • <leader>cs NERDComSexyComment
  • <leader>cm NERDComMinimalComment
  • <leader>cc NERDCommenterComment
  • <leader>cn NERDCommenterNested
  • <leader>cu NERDComUncommentLine

Buffers

command mode

  • :ls list buffers
  • :ls! list buffers including hidden
  • :b6 goto buffer 6
  • :b [TAB] goto buffer by name with auto-completion
  • :b# goto alternate buffer
  • :bd delete current buffer
  • :bd 6 delete buffer 6
  • :bd 6 23 delete buffers 6 and 23
  • :bd [TAB] delete buffer by name can do multiple
  • :22,27bd delete a range of buffers
  • :%bd delete entire range all buffers
  • :bd! adding a bang will delete the buffer even if changed!
  • :bf goto the first buffer in the list
  • :bn goto the next buffer in the list
  • :bp goto the previous buffer in the list
  • :bm goto the next modified buffer in the list
  • :bl goto the last buffer in the list
  • :sb 6 split window and goto buffer 6 s
  • :sbn split window and goto next buffer works with many above

Windows

command mode

  • :sp split window
  • :vsp vertical split window
  • :sp [TAB] split window and open a file with auto-completion
  • :vsp [TAB] vertical split window and open a file

normal mode

  • CTRL-wx exchange windows
  • CTRL-wv split window vertically
  • CTRL-wc close the focused window
  • CTRL-wo make the focused window the only window
  • CTRL-wp focus on previous window
  • CTRL-w CTRL-w cycle round windows
  • CTRL-w[hjkl] focus on different windows
  • CTRL-w[HRJL] move window position
  • a count can be user with above eg. 3<CTRL>wj

Insert Mode

insert mode

  • CTRL-w delete previous work
  • CTRL-t shift line right
  • CTRL-d shift line left

completions

  • CTRL-n next completion
  • CTRL-p previous completion
  • CTRL-e abort completion
  • CTRL-y stop completion and accept the currently selected entry

insert_expand mode

CTRL-X enters insert_expand mode

  • CTRL-x CTRL-e scroll window one line up
  • CTRL-x CTRL-y scroll window one line down

completions

  • CTRL-x CTRL-l complete line
  • CTRL-x CTRL-n search forwards for keyword
  • CTRL-x CTRL-p search backwards for keyword
  • CTRL-x CTRL-] search for tag
  • CTRL-x CTRL-v search for Vim commands
  • CTRL-x CTRL-s spelling for word before cursor

Sessions

command mode

  • :mks [FILENAME] save session to file
  • :mks! [FILENAME] save session to existing file
  • :source [FILENAME] reload session

Ultisnips

insert mode

  • trigger then [TAB] to expand the snippet
  • CRTL-j to move forward through placeholders
  • CRTL-k to move backward through placeholders
  • CRTL-[TAB] list snippets

EasyMotion

normal mode

  • <Leader><Leader>f{char} Find {char} to the right.
  • <Leader><Leader>F{char} Find {char} to the left.
  • <Leader><Leader>t{char} Till before the {char} to the right.
  • <Leader><Leader>T{char} Till after the {char} to the left.
  • <leader><leader>w beginning of word forward
  • <leader><leader>W beginning of WORD forward
  • <leader><leader>b beginning of word backward
  • <leader><leader>B beginning of WORD backward
  • <leader><leader>e end of word forward
  • <leader><leader>E end of WORD forward
  • <leader><leader>ge end of word backward
  • <leader><leader>gE end of WORD backward
  • <leader><leader>j line downward
  • <leader><leader>k line upward

Emmet

all modes

  • <C-e><C-e> expand coding

Vim folding commands

  • 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.
  • 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.

Scratch area

div>ul>ul

sudo synclient touchpadoff=1

No comments: