Skip to content

Instantly share code, notes, and snippets.

@justinhennessy
Last active December 15, 2015 22:29
Show Gist options
  • Save justinhennessy/5333624 to your computer and use it in GitHub Desktop.
Save justinhennessy/5333624 to your computer and use it in GitHub Desktop.
vi cheat sheet

Add something to the end of a line

1,$ s/$/",/g

Add something to the start of a line

1,$ s/^/"/g

Turn on/off line numbers

:set numbers

:set nonumbers

Puppet Lint "fix" scripts

vim -c %s/\"/\'/g -c wq (replace double quotes with single for strings without variables)

vim -c "g/'.*\$.*/s/\'/\"/g" -c wq (replaces single quotes with double for strings with variables)

vim -c :retab -c :wq (changes tabs to spaces, this relies on your vim config being right)

vim -c %s/\'true\'/true/g -c wq (replaces 'true' with true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment