Skip to content

Instantly share code, notes, and snippets.

@suzmas
Last active April 26, 2017 01:36
Show Gist options
  • Save suzmas/1f9f0ca4beb9d7dcebd859b8b8bbbda1 to your computer and use it in GitHub Desktop.
Save suzmas/1f9f0ca4beb9d7dcebd859b8b8bbbda1 to your computer and use it in GitHub Desktop.
Vim commands I use / find helpful while learning

Vim for Me

  • Set cwd to current directory:

    :cd %:p:h

  • Set args to all the files in cwd

    :args **/*

  • Delete all pattern matches in file

    :g/MATCH BEGIN/ .,/MATCH END/d

  • Delete pattern match in many files and save all changed Make sure your :args are set to the correct files (check this with just :args )

    :argdo g/MATCH BEGIN/ .,/MATCH END/d | update

  • Vsplit multiple files at once

    vim -O <file1> <file2> <file3> <etc...>

  • Find & replace all instances of whole word in file

    :% s/\<WORD TO FIND\>/NEW WORD/g

@sslampa
Copy link

sslampa commented Apr 26, 2017

Different Ways To Save and Quit

ZZ
:wq
:x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment