Skip to content

Instantly share code, notes, and snippets.

@aciccarello
Last active August 1, 2019 09:35
Show Gist options
  • Save aciccarello/d84fe5684cddc0788b71f371495c7de5 to your computer and use it in GitHub Desktop.
Save aciccarello/d84fe5684cddc0788b71f371495c7de5 to your computer and use it in GitHub Desktop.
My Vim Guide

Vim Tips

A collection of Vim tools that I keep forgetting. Many of these are focused on VSCodeVim. Not meant to be exhaustive.

Recommended Vim Guides:

Navigation

Multi cursor mode

As defined for VSCodeVim, multi cursor mode can be accessed from normal mode via gb. There is also a cmd/ctrl-d keybinding.

Multiple Windows

Vim can have split windows to view two or more files at once. These bindings work well in VS Code as well.

  • Ctrl + ws - split window
  • Ctrl + ww - switch windows
  • Ctrl + wq - quit a window
  • Ctrl + wv - split window vertically
  • Ctrl + w<hjkl nav key> - move cursor to another window

Commands

Undo all changes to file

This can also be used to get rid of the "modified" state in VS Code.

:e!

or

:edit!

Command combos

There are common combo commands made up of up to three parts which are composed like a phrase.

  1. Action (optional for t or f selections)
  • c Change
  • d Delete
  • v Visual select
  1. Selection
  • (none) [word/paragraph movement type]
  • i in [bracket/quote type]
  • a around [bracket/quote type]
  • t to [character type]
  • T backwards to [character type]
  • f to (including the selector) [character type]
  • F backwards to (including the selector) [character type]
  1. Selector
  • Word or paragraph type (e.g. w, e, b)
  • Bracket or quote type (e.g. [, ")
  • Character (e.g. a, ;)

Repeat Navigation

The t and f navigation commands (including their backwards equivalents) can be repeated

  • ; repeat forward
  • , repeat backward

Replace selected text with buffer

From Vim Tips Wiki

  1. Paste from normal mode: ciw Ctrl-R 0 Esc
  2. Paste via visual mode: viwp repeated with viw"0p

Join lines without space

Just using the J command will include a space between the two lines you are joining. Use gJ to join without a space though the indentation from the previous line is not removed.

Tools

Online Vim in JS Bin

JS Bin supports Vim keybindings in their editor. This is great for debugging issues.

Note: At last check the new editor did not.

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