Vim Notes

Published:

Vim notes, tricks, settings, etc.

Movements

Visual mode

  • ctr-o jump back to previous location

Swapping Esc with Caps

This is a system-wise key binding.

vimrc

 " absolute number for current line and relavetive numbers for everywhere else
 set nu rnu
 
 set updatetime=250
 " map jj to backspace in insert mode
 imap jj <BS>
 imap cw <Esc>ciw
 
 " remap jj to esc for input, visual and normal mode
 imap jk <Esc>
 imap kj <Esc>
 
 " oo for inserting a new line and 
 " nmap oo o<Esc>k
 " \o to insert a new line in normal mode
 nnoremap <Leader>o o<Esc>0"_D
 
 " theme: monokai
 syntax enable
 syntax on
 autocmd vimenter * nested colorscheme gruvbox
 set bg=dark
 
 " cursors
 set cursorline
 set cursorcolumn
 " steady block for visual mode, bar for insert
 let &t_SI = "\e[6 q"
 let &t_EI = "\e[2 q"
 
 " don't let cursor go below the last 5 lines
 set scrolloff=5
 
 " fix tab behaviors
 filetype plugin indent on
 " show existing tab with 4 spaces width
 set tabstop=4
 " when indenting with '>', use 4 spaces width
 set shiftwidth=4
 " On pressing tab, insert 4 spaces
 set expandtab
 
 " incrementally highlight as searchring
 set incsearch
 " case smart insensitive search, still check caps if explicity search caps
 set ignorecase smartcase
 
 " custom key bindings
 " Ctrl+y to yank to system clipboard under visual mode
 vnoremap <C-y> "+y
 
 "intall plug-ins with vim-plug
 call plug#begin()
 Plug 'morhetz/gruvbox'
 call plug#end()
 
 " swap gj/gk and j/k
 nnoremap j gj
 nnoremap gj j
 nnoremap k gk
 nnoremap gk k