Skip to content

Commit

Permalink
reference: update speaking vim page
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalli-johnny committed Jan 7, 2025
1 parent 04322ae commit 9fde255
Showing 1 changed file with 100 additions and 23 deletions.
123 changes: 100 additions & 23 deletions docs/reference/modal-editing/speaking-vim.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,105 @@
# Learning to speak Vim

Neovim is easier to learn and gain much more benefit from if you learn to speak commands as sentences.
Learning to speak the language of vim-style editing significantly accelerates the performance of communicating with the computer.

First learn some verbs:
The language is constructed from

- `c` change
- `d` delete
- `g` go,
- `v` visual select
- `y` yank (copy)
- [actions](#actions) to navigate or manipulate text
- [motions](#motions) defining the scope of a cursor movement
- [multipliers](#multipliers) defining the number of times an action or motion takes place
- [text objects](#text-objects) are common scopes within a text document

Then use those verbs with some modifiers
Actions are coupled with motions or text objects

- `'` mark
- `{ }` beginning/end of paragraph
- `0` start of line
- `^` first non white-space character of line
- `$` end of line
- `a` around
- `f` find (includes character)
- `i` inside a range (e.g. word, paren,)
- `s` surround
- `t` till (move just before specified character)
!!! TIP "keys are mnemonic or regex and have capitalised variants"
Keys were designed to be mnemonic where possible, e.g. ++"d"++ for delete and ++"c"++ for change

Common regular expression scopes are used, e.g. ++0++ first character, ++"$"++ last character

Keys often have a variant of the action in the capitalised key, e.g. ++shift++ ++"c"++ changes to end of line


## Actions

First learn some verbs, these are your actions:

++"c"++ change

++"d"++ delete

++"g"++ go

++"v"++ visual select

++"y"++ yank (copy)

!!! TIP "Double tap to act on current line"
++"d"++ ++"d"++ deletes the current line

++"y"++ ++"y"++ yanks (copies) the current line


## Motions

Then use those verbs with some motions

++"j"++ ++"k"++ ++"h"++ ++"l"++ move one character down, up, left or right

++"%"++ matching paren `() [] {}` (toggle between open and closed paren)

++grave++ mark character (specify existing mark character)

++open-brace++ ++close-brace++ beginning/end of paragraph

++0++ start of line

++"^"++ first non white-space character of line

++"$"++ end of line

++"a"++ around

++"f"++ find specified character forward, ++"F"++ find backward

++"i"++ inside a range (e.g. a text object like word, or parens)

++"s"++ surround

++"t"++ till (move just before specified character)


## multipliers

An action or motion can be repeated by a given number

++3++ ++"d"++ ++"w"++ deletes the next three words by repeating the action

++"d"++ ++3++ ++"w"++ deletes three words by repeating the motion (follows how this would be said in English)

!!! TIP "Relative line numbers"
Using relative line numbers an effective way to jump around the visible text of a buffer.

Each line shows how many lines away it is from the current line.

++"j"++ ++"k"++ navigation motions will move down or up the number of lines, e.g. ++1++ ++0++ ++"j"++ will jump down 10 lines.





## Text Objects

Then learn the text objects you can apply verbs and modifiers too

- `b` block/parentheses
- `p` paragraph,
- `s` sentence
- `t` tag e.g. html/xml
- `w` word
++"b"++ **block/parentheses** a text block or text between parens

++"p"++ **paragraph** text to the next blank line

++"s"++ **sentence** text to a full stop character

++"t"++ **tag** e.g. html/xml tag and its contents

++"w"++ **word** - start of next word, ++"W"++ ignores punctuation

## Examples of speaking Vim

Expand All @@ -56,3 +125,11 @@ Practice speaking evil with these examples
| `y y` | yank (copy) current line |
| `y w` | yank (copy) current word |
| `y @ a` | yank (copy) to mark `a` (`m a` creates a mark called `a`) |


<!--
- actions motion
- actions number motion
- actions text object
- actions number text object
-->

0 comments on commit 9fde255

Please sign in to comment.