Vim
Vim is a highly configurable and versatile text editor that is primarily utilized for editing text files in a terminal or command-line interface. It was initially released in 1991 as a clone of the Unix text editor Vi. Vim stands for "Vi IMproved."
Vim as a language
Thinking about Vim as a language.
Verbs
Are the actions we take, and they can be performed on nouns.
- d: delete
- c: change
- y: yank (copy)
- v: visually select (V for line vs. character)
Modifiers
Are used before nouns to describe the way in which you're going to do something.
- i: inside
- a: around
- NUM: number (e.g.: 1, 2, 10)
- t: searches for something and stops before it
- f: searches for that thing and lands on it
- / or ?: find a string (literal or regex)
Nouns
Nouns are objects you do something to.
- w: word
- s: sentence
- ): sentence (another way of doing it)
- p: paragraph
- }: paragraph (another way of doing it)
- t: tag (think HTML/XML)
- b: block (think programming)
Sentences
- Delete two words: `d2w`
- Change inside sentence (delete the current one and enter insert mode): `cis`
- Yank inside paragraph (copy the paragraph you're in): `yip`
- Change to open bracket (change the text from where you are to the next open bracket): `ct<`
Search
- /{string}: search for string
- t: jump up to a character
- f: jump onto a character
- \*: search for other instances of the word under your cursor
- n: go to the next instance when you've searched for a string
- N: go to the previous instance when you've searched for a string
- ;: go to the next instance when you've jumped to a character
- ,: go to the previous instance when you've jumped to a character
Search and Replace: `%s/search/replace/gc`.
- Optionally add `/g` at the end to replace every instance on each row.
- Optionally add `%` to the beginning to search the whole file.
- Optionally add `c` at the end to ask for confirmation.