VIM Cheatsheet 1 - Navigation and Editing in Files


This VIM cheat sheet will be a quick reference guide that lists commonly used commands and shortcuts. This serves as a handy reference for VIM users, especially those who are new to VIM or may not use it frequently.



1. Navigating in the file

 

Shortcut                                         

 

Function

[[ or gg

Moves to the first line of the file

]] or G

Moves to the last line of the file

nG or :n

Moves to nth line

H

Moves to the top of the visible screen

L

Moves to the bottom of the visible screen

M

Moves to the middle of the visible screen

0

Moves to the beginning of the line

$

Moves to the end of the line

%

Moves to matching paranthesis,bracket or brace

 

2. Editing Files

 

Shortcut                                         

 

Function

> 

Shift Right (Indent)

< 

Shift Left (Indent)

(V)+ c

After entering visual mode, pressing ‘c’ changes the highlighted/selected text

C

Change the rest of the current line

(V)+y

Yank/Copy the highlighted/selected text to clipboard.

(V)+d

Delete the highlighted text

yy or :y or Y

Yank/Copy the current line

nyy

Copy n lines

dd or :d

Delete the current line

dgg

Deletes everything from the cursor to file begining

dG

Deletes everything from the cursor to file end

p

Pastes the copied/yanked or deleted lines below the current line

P

Pastes the copied/yanked or deleted lines above the current line

x

Delete the single character after the cursor

X

Delete the single character before the cursor

r

Replace a single character

R

Replace multiple characters until ESC is pressed

J

Join line below to the current line with one space in between

u

Undo

U

Undo the last changes in the current line

Ctrl+r

redo

~

Change the case of characters. In Visual mode highlighted characters case can be changed. In command mode character under the cursor case can be changed.
























Post a Comment

Previous Post Next Post

Contact Form