I'm an avid user of vim. I even went as far as to try and bring it to the browser. One of my co-workers noticed I used vim and they had gotten through the basics. There is a lot of good material out there like vimcasts.org. But this was an opportunity to reflect on advice I might give.
The first thing to establish is that vim operates with a grammar, count, verb, motion. I wanted to provide a short list of commands I frequently use, and I want to provide short explanation, let me know if I'm too abbreviated.
Search for word under cursor: *
Jump to matching bracket: %
Change inside quotes: ci"
Copy around quotes: ya"
The first two fall in the category 'motion' and the last two are a composition.
Verbs -> change c
, yank y
, delete d
Adverb -> inside i
, around a
Motion -> inside quotes i"
, around quotes a"
Here we see that a motion is made up of that adverb and a context. These two motions will exclude or include that context.
"hello" i" => hello
"hello" a" => "hello"
The primary context I use is:
Context: quote "
, parens (
, word w
Do it again: .
Period is the repeat operation. It take your last edit operation and replays it at the new cursor location. The value here is being able to form edits which can be repeated. But even multiple edits can be repeated by recording a macro.
Macros require being able to navigate text in a generic manner. This would mean no mouse. Macros are temporary, good for targeting the task at hand. I'm not covering enough to make these useful, but here is how to create and use.
Record macro to letter 'q': qq
Replay macro for letter 'q': @q
Undo tree. This is not something I use often and it can be a pain to navigate. The undo trees keeps edit history across new edits, this happens when you undo and make edits to the file. In most editors the history before the undo is lost and you can only navigate with the new edits, vim let's you switch the undo branch being navigated.
Go to older branch: g-
Go to newer branch: g+
Top comments (0)