Vim cheatsheet

less than 1 minute read

Updated:

Something that I need for VIM editor

vim

#include <stdio.h>
// main.c

int main(void)
{
	printf("Hello World!\n");
}

open

vim main.c

open and point particular line

vim +5 main.c

Vim modes are:

  • normal
  • input
  • visual
  • exit

normal mode: type “Esc” v1

input mode: change into normal mode first, and, type “a” to append type “i” to insert v2

exit mode: change into normal mode first, and, type “:” “:w” to write(save) file “:q” to quit “:wq” to write and quit v3

To copy lines, change to normal mode by typing “Esc”, and type “yy” to copy single line, Or to copy multiple lines, for example, 10 lines,
type “10”, and type “yy” v4

”%” or (shift + 5) to go to parenthesis that is matched v5 v6

find and replace all

press “:” to switch to command mode

“%s/pair/my_pair/g”

Leave a comment