DEV Community

Guilherme
Guilherme

Posted on

VIM - Insert and Change

As I mentioned in the post before, VIM is one of the techs I want to learn this year. VIM has been always present since my early days in tech but I never spend time on it. I guess now it is time to make an amend with the past. 😅

Insert Mode:

i - insert before the cursor
I - insert in the beginning of the line
a - insert after the cursor
A - insert in the end of the line
o - insert below the line
O - insert before the line
[count] [motion] text - repeat the motion [count] times

Examples:
8 i * - insert the character * 8 times in the same line
8 o # - create 8 new lines starting with #

Change:

R - overwrite the existing text
r - Replace one character
c w - change the word
c c - Change the entire line
c $ or C - replace from your current cursor to the end of the line
~ - Switch character from upper/lower case.
g ~ w - Switch a letter from upper/lower case.
g ~ $ or g ~ ~ - Switch the line to upper/lower case.
g U w - make the word uppercase
g U U - make all the line uppercase
g u w - make the word lowercase
g u u - make all the line lowercase

Joining lines:

J - Join lines with a space by the end of the current line.
g J - Join lines without a space be the end the current line.
[count] J - Joint [count] lines together

Top comments (0)