" *** *** *** Key Mappings *** *** *** " ************************************ " Quick toggle between buffers noremap j :b# " Add semicolon or comma to the end of the line nnoremap ;; A; nnoremap ,, A, " Maintain the cursor position when yanking a visual selection vnoremap y myy`y vnoremap Y myY`y " Delete last character of line nnoremap x $x " Open vim config in a new buffer, reload vim config nnoremap ve :e $MYVIMRC nnoremap vr :source $MYVIMRC " Delete current buffer nnoremap X :bd " Delete all buffers nnoremap da :bufdo bdelete " Save current buffer nnoremap sf :w " Allow gf to open non-existent files map gf :edit " Reselect visual selection after indenting vnoremap < >gv " Set spell checker to `s` " zg (good), zG (good temp), zw (wrong), zW (wrong temp) nnoremap rs :set spell! " Switch off highlighting nnoremap h :nohlsearch " Toogle list nnoremap l :set list! " Indent the whole source code nnoremap pf gg=G'' " Reverse the mark mapping nnoremap ' ` nnoremap ` ' " Visuall select of just pasted content nnoremap gp `[v`] nnoremap gy `[v`]y " When text is wrapped, move by terminal rows, not lines, unless a count is provided noremap j (v:count == 0 ? 'gj' : 'j') noremap k (v:count == 0 ? 'gk' : 'k') " Open a quickfix window for the last search nnoremap ? :execute 'vimgrep /'.@/.'/g %':copen " Faster linewise scrolling noremap 3 noremap 3 " Keep the window centered noremap G Gzzzv noremap n nzzzv noremap N Nzzzv noremap } }zzzv noremap { {zzzv " Close all buffers nnoremap XX :qa " Add lines in NORMAL Mode nnoremap gn ok nnoremap gN Oj " Change to the folder of the current file nnoremap cf :cd %:p:h:pwd " Quickfix Window nnoremap qo :copen nnoremap qc :cclose " Exit INSERT MODE with 'jk' inoremap jj " Reformat a line into a block nnoremap q gqip " Reformat a block into a line nnoremap qq vipJ " Easier split navigation nnoremap nnoremap nnoremap nnoremap " Mapping for easier OmniCompletion inoremap inoremap inoremap inoremap inoremap " Remap Jump to Tag nnoremap ü nnoremap Ü " Open for Markdown in iA Writer nnoremap ia :silent !open -a iA\ Writer.app '%:p' " Custom Text Objects let pairs = { ":" : ":", \ "." : ".", \ "" : "", \ "*" : "*", \ "-" : "-", \ "_" : "_" } for [key, value] in items(pairs) exe "nnoremap ci".key." T".key."ct".value exe "nnoremap ca".key." F".key."cf".value exe "nnoremap vi".key." T".key."vt".value exe "nnoremap va".key." F".key."vf".value exe "nnoremap di".key." T".key."dt".value exe "nnoremap da".key." F".key."df".value exe "nnoremap yi".key." T".key."yt".value exe "nnoremap ya".key." F".key."yf".value endfor