VIM

[toc]

Modes

  1. Normal - Esc
  2. Insert - i, a, c
  3. Visual - v, V, Ctrl-v
  4. Command - :, /

Operators

Text Objects

Motions

TRICK

DEMO

Always be Scrolling

Basic Editing

Bookmarks

Ctrl-] and Ctrl-t - PM

Ctrl-O and Ctrl-I - cycle through :jumps and g;, g cycle thru :changes

DEMO

Set bookmarks 'V as ~/.vimrc for easy setting

Master VIM

.vimrc

syntax on 
filetype plugin indent on " Enable file type based on indentation.
set autoindent
set expandtab " Expand tabs to spaces. Essential in Python.
set tabstop=4 " Num. of spaces tab counted for.
set shiftwidth=4 " num. spaces to use for autoindent.
set backspace=2 " fix backspace bevaiour on most terminals.
colorscheme murphy

Basic

Swap files

Default tracking changes in swap files that are auto-gen during editing, recovered via VIM or SSH

Motion

Simple edit change

Persistent undo and repeat

loop through keyword in help

Advanced Editing and Motion

plugin

Workspace

Buffers

arglist

Windows

# binding for ease split in vimrc
" Fast split navigation with Ctrl + hjkl
noremap <c-h> <c-w><c-h>
noremap <c-j> <c-w><c-j>
noremap <c-k> <c-w><c-k>
noremap <c-l> <c-w><c-l>

Tabs

Folds

Folding methods following foldmethod

indent - langs having indentation syntax

expr - regex based and extremely powerful

marker - special markup like {{{ }}}

syntax - not every lang supported

diff - auto used when operating diff mode

File tree

plugins

Movement in Text

			gg	
			?
			H
			{
			k
^ F T ( b ge h  l w e ) t f $
			j
			}
			L
			Ctrl+f
			/
			G

Jump into INSERT

Searching / and ?

Searching across files

ack

Text Object

EasyMotion

Registers

Copying from outside VIM

Plugin

Managers

if empty (glob ('~/.vim/autoload/plug.vim'))
	silent !curl -fLo ...
	autocmd VimEnter * PlugInstall --sync | source $MYVIMRX
endif

Profiling speed

MODE

Text

Autocomplete

YouCompleteMe

Navigating code base with tags

Exuberant Ctags

Build, Test, Execute

Integrating Git Vim - vim-fugitive

Resovling conflicts with vimdiff

git checkout -b branch-tmp
# edit some codes
git add . && git commit -m "Branch-chnage"
git checkout master
# edit some codes differently
git add . && git commit -m "Master-change"
git merge branch-tmp
# stdout: Conflict
git mergetool 

code · notebook · prose · gallery · qui et quoi? · main