Gvim Commands Notes (1)
Gvim Commands Notes (1)
e Debian, ubuntu)
sudo apt install vim
--------------------
For Redhat like OS(i.e Redhat, fedora, centos, centos stream)
sudo yum install vim
gVim Installation:-
For debian like OS(i.e Debian, ubuntu)
sudo apt install vim-gtk3
----------------------------
For Redhat like OS(i.e Redhat, fedora, centos, centos stream)
sudo yum install gvim
-----------------------
***********************************************************************************
******
GVim (Graphical Vim) is a GUI version of the Vim text editor, providing a graphical
interface and additional features while retaining the powerful command-line
capabilities of Vim. Here is a detailed explanation of various GVim commands and
their functionalities:
:sp ~/.vimrc This command to open .vimrc file its an hidden file.In that file types
below commands by pressing i-insert mode
set hlsearch-->highlight search terms
set incsearch show search matches as you type
set number -->set line number
set showmode--->always show what mode we're currently editing in
set autoindent --->always set autoindenting on
set tabstop=4 --->a tab is four spaces
set syntax=ON -->syntax highlighting
set nocompatible -->set nocompatible is used in GVim (and Vim) to switch from "Vi-
compatible" mode to "Vim-enhanced" mode.
set backspace=indent,eol,start --->allow backspacing over everything in insert mode
set guifont=consolas:h17--->is used in GVim (Graphical Vim) to specify the font and
font
size for the text displayed in the GUI version of Vim.
syntax on --->in GVim (and Vim) is used to enable syntax highlighting. Syntax
highlighting is a feature that displays text—especially source code—
in
different colors and fonts according to the category of terms.
Gvim modes
-----------
Insert mode(i,I,A,a)
escape mode(command mode or normal mode)(Esc)
visual mode(v,V,ctrl+v)
recording mode q
In GVIM, insert mode allows you to insert new text into the document. Here is a
list of some commonly used insert mode commands:
'i'--insert text before the cursor
'I'--insert text at the begininng of the current line
'a'--Append text after the cursor
'A'--Append text at the end of the current line
'o'--insert a new line below the current line and start insert mode
'O'--insert a new line above the current line and start insert mode
'r'--replace one character under the cursor
'R'--replace multiple character,starting at cursor position
's'--Delete the character under the cursor and insert new text.
'S'--Delete the current line and insert new text
'C'--Delete to the end of the line after the cursor and insert new text
'cc'--Delete the entire line and insert new text
'cw'--Delete the word under the cursor and insert new text
'c$'--Delete to the end of the line & insert the new text.
'Crtl+p'--->pool of words only command used in insert mode.
File Management:
________________
create,open,save,close/quit
Deleting
---------
x - Delete the character under the cursor.
dw - Delete a word.
dd - Delete an entire line.
d$ - Delete from the cursor to the end of the line.
d0 - Delete from the cursor to the beginning of the line.
dgg - Delete from the cursor to the beginning of the file.
dG - Delete from the cursor to the end of the file.
Navigation
-----------
h - Move left. ex:10h-move 10 character left side
j - Move down. ex:10j-move 10 lines down
k - Move up. ex:10k-move 10 lines up
l - Move right.ex:10l-move 10 characters right side
gg - Go to the beginning of the file.
G - Go to the end of the file.
0 - Move to the beginning of the line.
$ - Move to the end of the line.
w - Move to the next word.
b - Move to the previous word.
Ctrl+o - Move to the previous cursor position.
Ctrl+i - Move to the next cursor position.
Ctrl+f - Move the contents of the file in forward
Ctrl+b - Move the contents of the file in bachward
Window Management
------------------
:split or :sp - Split the window horizontally.
:vsplit or :vsp - Split the window vertically.
Ctrl+w w - Switch between windows.
Ctrl+w q - Quit the current window.
Ctrl+w s - Split the window horizontally and switch to the new window.
Ctrl+w v - Split the window vertically and switch to the new window.
Ctrl+w h - Move to the left window.
Ctrl+w j - Move to the window below.
Ctrl+w k - Move to the window above.
Ctrl+w l - Move to the right window.
Searching
---------
/pattern - Search for pattern.
?pattern - Search backwards for pattern.
n - Repeat the search in the same direction.
N - Repeat the search in the opposite direction.
:%s/old/new/g - Replace all occurrences of old with new in the entire file.
:s/old/new/g - Replace all occurrences of old with new in the current line.
* search the word
/ search the word
:%s/pattern-to_search/pattern to replace/g
:%s/pattern-to_search/pattern to replace/gc
:%s/pattern-to_search/pattern to replace/
:line no.s/pattern-to_search/pattern to replace/
:lower_range,upper_ranges/pattern-to_search/pattern to replace/g
:lower_range,upper_ranges/pattern-to_search/pattern to replace
:%s/pattern-to_search/pattern to replace/gc
Replace with Hi (y/n/a/q/l/^E/^Y)?
____________________________________________
y: Replace this instance and move to the next match.
n: Skip this instance and move to the next match.
a: Replace all remaining matches without further confirmation.
q: Quit the search and replace operation.
l: Replace this instance and then quit.
^E (Ctrl+E): Scroll the screen up.
^Y (Ctrl+Y): Scroll the screen down.
Visual Mode
------------
v - Enter visual mode (select text character-wise).
V - Enter visual line mode (select entire lines).
Ctrl+v - Enter visual block mode (select columns).
'I' inserts to the left of visual block
'A' inserts to the right of visual block
c--> to change the visual block data
Tabs
-----
:tabnew or :tabe filename - Open a new tab with filename.
:tabclose - Close the current tab.
:tabnext or :tabn - Switch to the next tab.
:tabprevious or :tabp - Switch to the previous tab.
:tabfirst - Go to the first tab.
:tablast - Go to the last tab.
Advanced Commands
Macros
q{register} - Start recording a macro into the specified register.
q - Stop recording the macro.
@{register} - Execute the macro stored in the specified register.
@@ - Repeat the last executed macro.
Vim Macros(vim recording)
In command mode it works
to start recording press 'q' followed by a register name (it can be number or
alphabet)
to stop recording press 'q'
to play recording press '@register name'