Why Gvim?
- Editor(writes)
- We find it less difficult
Different editors
- Notepad ++
- Visual studio code
- Atom
- Word , ect
- GVim -? Focus?
- Sublime
Windows : GVIM
LINUX : VIM
WHy GVIM?
- Because of commanding ability (Linux commands support)
- Work flow is easy(commands)
- Fast and effective(Commands)
- Time saving (commands)
Number of modes:
1. Escape mode (ESC) : Command
2. Insert mode (Shift+I or i) : Insert word/sentences
Set Line number
: se nu or :set nu
To remove line numbers
: set nu : se nonu
Don't set line number
: se nonu
: set nonu
Syntax highlight
: syntax on
// Few of the commands will applicable to only Linux OS and few will be applicable
to WIndows OS
Linux OS
: setf verilog
: setf vera
Syntax lowlight (Off)
: syntax off
Open file
: vspl (Vertical split)
: spl (Horizontal split)
Save
: w
Save all(Only when multiple files needs to be saved)
: wa
Quit
: q
Quit all
: qa
File is saved or not?
Check + sign on top or at the bottom of the file
Save & quit
: wq
Save & quit all
: wqa
Quit without save
:q!
Don't save but quit all
: wqa!
Quit without saving all files
: qa!
New tab
: tabnew [Link]
Click on O -> to go to next line
How to get suggestions while typing
- Ctrl+P => P
Switching between files
- Ctrl+W => W , Right arrow , Left arrow (vspl)
- Ctrl+W => W, Up/Down (spl)
: vspl .
-> . Current directory
-> List of files in the present directory
: vspl CTRL+D
Navigation
gg -> first line of the file
G -> Last line of the file
kajohl
g -> small case
G -> Upper case
k - up
j - down
h - left
l - right
To point to the specific line number
: line_number
Ex : 50
10 line up
10k
10 lines down
10j
10 words left
10h
10 word right
10l
All windows size should be equal
- Ctrl+W,=
Maximize /Minimize a screen in vertical split
- Ctrl+W,number,Shift+< or Shift+>
Ex : Ctrl+W100> , Ctrl+W100<
word movement
w - move one word forward
nw - move n words forwards
b - move one word backward
nb - move n words backward
Copy
yy - one line copy
nyy - n lines copy
Paste
p - Paste once
np - Paste n times
Delete
dd - delete one line
ndd - delete n lines
Undo operation
u
Redo operation
Ctrl + R
Select all lines in a file
ggVG
Select all lines in a file and copy
ggVGy
Select all lines in a file and delete
ggVGd
dG -> delete the lines from wherever you are till the end
dgg -> delete the lines from wherever you are till the top
:lower_range,upper_rangey
:lower_range,upper_ranged
yG -> copy from wherever you are till the end
ygg -> copy from wherever you are till the top
Replace
r - one char replace
nr - n char's replace
Change word
cw - one word change
ncw - n word's change
Dot - Record's the operation from one ESC to another ESC
.
Search and Replace
: r1,r2s/pattern_to_search/pattern_to_replace/ -
: r1,r2s/pattern_to_search/pattern_to_replace/g - Global
:%s/pattern-to_search/pattern_to_replace/
:%s/pattern-to_search/pattern_to_replace/g
Turn off hightlight
: noh
Lower case to upper case
Shift+V,Shift+U
Upper to Lower
Shift+V , u
Select one line
Shift+V (Visual line)
Select block of lines
Ctrl+V (Visual block)
Change line
Shift+V -> Select line
c - change the line
To comment all lines at a time
Ctrl+V , Shift+G , Insert Backslash , ESC
Ctrl+V , Line_number , Shift+G , Insert anything ,ESC
Search
/pattern_to_search
?pattern-to_search
type Shift+8
n - searches down
Shift+N - searches up
To open file which is included within the files
-> CTRL+W+F
:vspl Ctrl+D
0 : Goes to the first word in a line
^ : first non-white char in a line
$ ; End of the current line
% : Searches paranthesis
e : End of the current word
:se ic -> identical characters
: se noic - non-identical characters