Skip to content

Instantly share code, notes, and snippets.

@HelioCampos
Last active May 4, 2020 07:06
Show Gist options
  • Save HelioCampos/c908fceb7ed192b16cfc to your computer and use it in GitHub Desktop.
Save HelioCampos/c908fceb7ed192b16cfc to your computer and use it in GitHub Desktop.
vim_commands
# VIM COMMANDS
## SUBSTITUTIONS
### Substitute [:<WORD>] by ['<WORD>'] on chef recipes
:1,$ s/[[]:\([^]]\+\)[]]/['\1']/gc
### Substitute pattern in mutiple lines to another thing
:1,$ s/local_action:\n module: \([^\n]\+\)/\1:/gc
### Substitute WORD => , to :WORD => node[\'fm_redis\'][\'confs\'][\'general\'][\'WORD\'], on lines 18 to 42
18,42 s/\([a-z_]\+\) => ,/:\1 => node[\'fm_redis\'][\'confs\'][\'general\'][\'\1\'],/gc
### Substitute node\['fm_redis']['confs']['WORD'] to WORD
35,56 s/node\[\'fm_redis\'\]\[\'confs\'\]\[\'\([^']\+\)\'\]/\1/gc
## MOVING THINGS
### Move types from position
:3 s/\(FIXED_PATTERN\)\([^-]\+-\)\([^-]\+-\)\([^-]\+-\)/\1\3\4\2/gc
## DELETION COMMANDS
### delete a line
dd
### delete n lines
dnd
### delete partf of a word starting from where the cursor is in (delete word from)
dw
### delete a complete word where the cursor is positioned over (delete inside word)
diw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment