vim tricks

2020-09-04 06:23

terminal mode

n to switch to terminal normal mode

insering digraphs to search (and replace)


quickfix with c and linking

    :set makeprg=gcc\ -lncurses\ %

cd to current file parent directory

    :cd %:p:h

fix common filetype errors

remove unicode bom

    :set nobomb

change file format

    :w ++ff=dos
    :w ++ff=unix
    :w ++ff=mac

pretty print json with Python

    :%!python -m json.tool

    :execute '%!python -m json.tool

force redraw


buffer-local mappings (e.g. only map scrolling when browsing help files)

    :nnoremap <buffer> <Down> <C-e>

enter unicode characters

  1. enter insert mode
  2. u2713

split from tab

    :vert sb#

bulk rename files in vim

    :%s/.*/mv -i & &/g
    :w !sh
    :redir @a <bar> :%s_^$__n <bar> redir END <bar> "ap