Skip to content

Instantly share code, notes, and snippets.

@semick-dev
Last active September 23, 2024 10:00
Show Gist options
  • Save semick-dev/66669c942b60ae48f58c70e347215e6c to your computer and use it in GitHub Desktop.
Save semick-dev/66669c942b60ae48f58c70e347215e6c to your computer and use it in GitHub Desktop.
A vim reference for myself.

Vim notes

Installation via marketplace

Start with VsCodeVim marketplace extension.

Normal Mode

To return to normal mode:

  • esc
  • ctrl+c
  • ctrl+[

Otherwise, the commands follow a grammar:

<valid action> = <command> <locator> <motion> | <locator> <motion> | <motion> <direction>
                 | <locator> <repeat>? | <search>
<command> = d | c | y | v | > | <
<search> = / <search term> <enter> <searchresult>
<searchresult> = n <searchresult> | N <searchresult> | n | N
<motion> = h | j | k | l
<direction> = $ | _
<locator> = <integer>? f <character> | <integer>? t <character>
           | <integer>? F <character> | <integer>? T <character>
           | <integer>
<repeat> = ; | ,
<character number> = position on the line
<character> = an ascii character
KeyBind Command
x delete a character
h cursor left
j cursor down
k cursor up
l cursor right
w skip one word forward
b skip one word backward
d delete (repeat for single line delete)
< De-dent line
> Indent line
c ?
y yank
p paste
_ Goes to the beginning of the line
$ Goes to the end of the line
0 Goes to the 0th item of the line
; Next match
, Previous match
/ Initiate search
n Next search match
N Previous search match
f + <character> find forward from cursor on to next
t + <character> find forward from cursor next to to next
F + <character> find backward from cursor on to next
T + <character> find backward from cursor next to to next

Motion

           ↑
           k         Hint: The h key is at the left and moves left.
       ← h   l →           The l key is at the right and moves right.
           j               The j key looks like a down arrow.
           ↓

Insert Mode

i to enter the mode before the cursor. a to enter the mode after the cursor. O to enter the mode on a new line before the cursor. o to enter the mode on a new line after the cursor.

Visual Mode

v to enter the mode. shift + v to enter an enforced multiline select. (visual line mode)

Command Mode

:

:q to quit a window with focus

OR In command mode (:) ctrl-p for previous ctrl-n for next commandvim

ctrl-o to jump the cursor back to previous position`

Find

  • /
  • search term
  • enter
  • n for next occurence
  • N for previous occurence

Tags

A tag is an identifier that appears in a tags file. A tags file must be generated before it can be used, but once one exists, it'll keep track of stuff in a file. For instance in C function names will be tags. You will be able to advance between tags with ctrl-t for previous tag.

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