Vim 102
Who?
- Already have basic navigation knowledge
- Want to learn how to edit text more easily on the same line
Search occurence
- t<char> : until next occurence (not included)
- f<char> : until next occurence (included)
- T<char> : until previous occurence (not included)
- F<char> : until previous occurence (included)
Any movement can take a count.
For example, move to the second next g character
2fg
Example
Jump to the f letter then delete until the d.
The quick brown fox jumps over the lazy dog.
Example
Jump to the f letter then delete until the d.
The quick brown fox jumps over the lazy dog.
Solution:
fftbty
Text-Objects
- Same as motion but it operates on the whole object.
- No need to move to the beginning of the object.
- It can't take a count
Text-Objects
- i : operates inside the object, doesn't include the spaces around
- a : operates inside and around the object, does include the spaces around
For example, delete the current word when the cursor is in the middle of the word
diw
Example
Jump to the o letter then copy the current word. Paste it at the end. Go back to the a character and delete the word.
The quick brown fox jumps over the lazy dog.
Example
Jump to the o letter then copy the current word. Paste it at the end. Go back to the a character and delete the word.
The quick brown fox jumps over the lazy dog.
Solution:
foyiw$pFadaw
Bonus
There are already tons of text-objects
- ' : works with single quotes string
- " : works with double quotes string
- ( : works with parenthesized block
- <, [, {, ...
If not enough, some plugins exist: CamelCase, arguments, indentation, elixir functions...
Vim 102
By Kevin Disneur
Vim 102
- 1,397