Skip to content

Instantly share code, notes, and snippets.

@EdwardAndrew
Last active August 18, 2018 16:21
Show Gist options
  • Save EdwardAndrew/e62cb963244ac250bc316ad5c5eb0e53 to your computer and use it in GitHub Desktop.
Save EdwardAndrew/e62cb963244ac250bc316ad5c5eb0e53 to your computer and use it in GitHub Desktop.
Useful vim notes.

File Searching

  • set path+=** to recursively search all directories and sub-directories.
  • set wildmenu for tab completion.
  • gf go to file under cursor.
  • For nicely formatted netrw we can add the following to .vimrc:
    let g:netrw_banner=0
    let g:netrw_browse_split=4
    let g:netrw_altv=1
    let g:netrw_liststyle=3
    let g:netrw_list_hide=netrw_gitignore#Hide()
    let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
    

Tags

  • Install ctags.
  • Add command! MakeTags ctags -R . to .vimrc.
  • Vim can read the generated tags file from MakeTags. You could also make the ctags command run when you save the file.
  • ^] go into tag.
  • g^] search for ambigous (multiple) tags.
  • ^t come out of tag.

Autocompletion

  • ^x^n autocompletion from just this file.
  • ^x^f for filenames.
  • ^x^] for tags only.
  • ^n or ^p anything specified by 'complete' option.
  • Use ^n or ^p to traverse options.

Snippets

  • Add skeleton files to .vim/ folder, then use add mapping such as the following to .vimrc : nnoremap ,html :-1read $HOME/.vim/.skeleton.html 3jwf>a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment