Skip to content

Instantly share code, notes, and snippets.

@stefthoen
Last active August 29, 2015 14:03
Show Gist options
  • Save stefthoen/162c126c9a6dfda1afd2 to your computer and use it in GitHub Desktop.
Save stefthoen/162c126c9a6dfda1afd2 to your computer and use it in GitHub Desktop.

Normal mode

  • ^W + ^= Make split windows equal size.
  • @: Repeat the last Ex command.
  • gv Select last visual select.
  • = Auto-indent.
  • =G Auto-indent to the end of the file.
  • =i} Auto-indent inside de bracket.
  • s Deletes the character and enters Insert mode.
  • f Searches for character in line. ; searches for next instance, , searches for previous instance.
  • * Searches for all occurrences of word that's under the cursor.
  • daw Delete a word. Different from dw because it deletes the full word, even though the cursor is not placed on the first character.

Insert mode

  • <C-h> Delete back one character (backspace).
  • <C-w> Delete back one word.
  • <C-u> Delete back to start of line.
  • <C-k> Delete forward to end of line.
  • <C-r> Pasted yanked text without leaving the insert mode. If yanked text contains new line characters, <C-r><C-p>0 will take care of fixing indentation issues.

Visual mode

  • We can visually select all 3 lines and then run command :normal A; that will execute A; (append ;) for each line. Alternatively, we can run same on the whole content of the file with :%normal A;. What if we did a single modification on the first line of the above snippet appending ; at the end of the line with A;. We can repeat that command by selecting the lines 2-3 and running the dot command over visual selection with :normal .
  • :sort Sorts selected lines alphabatically.

Command mode

  • %s/foo/bar/g Replaces foo by bar in whole file.
  • :args app/_/scss/modules/*.scss Loads all files in modules in args.
  • :argsdo %s/replace/with/g Replace something in all files in the arguments list.
  • :argdo update Save all the files in the arguments list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment