Skip to content

Instantly share code, notes, and snippets.

@zackfern
Last active December 23, 2015 04:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save zackfern/5878923 to your computer and use it in GitHub Desktop.
Save zackfern/5878923 to your computer and use it in GitHub Desktop.

Sublime to Vim

  • Use Control+W instead of Alt+Backspace
  • To unindent a line, use Ctrl+D
  • To indent a line, use Ctrl+T
  • Upper-case J joins lines (same as Cmd+J in Sublime Text)
  • Use :edit! to force a reload of the current file from disk.
  • To skip to the first non-whitespace character on a line, press ^
  • yy copies (yanks) a line

Window Commands

  • To close all the windows, use :qa
  • To save and quit all, :wqa
  • :wincmd / :winc allows you to execute commands like you would calling Ctrl+W (for example, :wincmd q is the same as Ctrl+W q)

Resizing

  • :res N - Changes the height of a window to be N rows.
  • :res +N - Adds N rows to the height of a window
  • :res -N - Removes N rows from the height of a window
  • :vertical res N - Changes the width of a window to be N characters
  • :vertical res +N - Adds N characters to the width of a window
  • :vertical res -N - Removes N characters from the width of a window
  • Ctrl-W = - Makes all windows visible in VIM approximately the same height.
  • Ctrl-W _ will make the current window as large / big as it can be.
  • :only will close all windows except the current one

Other Cool Shit

  • Use :w !diff % to see a diff between the last saved version and the current version.
  • Use :w !pbcopy to copy an entire file to the system clipboard (OS X).
  • Remove duplicates while sorting, :sort -u
  • Sort in reverse, :sort!
  • Run a macro on every line of a visual selection, :'<,'>normal @q
  • Type gi and Vim will take you back to where you were last in insert mode and put you back into insert mode.
  • You can use ci" or ci' to clear out and insert inside of double / single quotes, say to replace a sentence / word.
  • You can use da_pattern_ to delete around patern. For example, da" will delete the entire "Quoted Text."
  • Ctrl+O will take you back to where you were before you jumped around your file.
  • Ctrl+I will take you forward to where you were after you jumped back in your file.
  • :jumps will display your jumps.

Starting Vim without loading .vimrc

Use the -u option and pass it NONE (vim -u NONE):

-u {vimrc}

Use the commands in the file {vimrc} for initializations. All the other
initializations are skipped. Use this to edit a special kind of files.
It can also be used to skip all initializations by giving the name "NONE".
See ":help initialization" within vim for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment