0% found this document useful (0 votes)
271 views3 pages

Detail - Commands of Gvim

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
271 views3 pages

Detail - Commands of Gvim

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

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.

Basic Commands
Opening and Saving Files
-------------------------
:e filename - Open a file named filename.
:w - Save the current file.
:w filename - Save the current file with the name filename.
:wa - Save all open files.
:wq - Save the current file and quit.
:wqa - save all and quit
:q - Quit GVim.
:q! - Quit GVim without saving changes.
:wq! - Save the file and quit forcibly.
:x or ZZ - Save and quit if there are changes.

Editing
--------
i - Enter insert mode before the cursor.
I - Enter insert mode at the beginning of the line.
a - Enter insert mode after the cursor.
A - Enter insert mode at the end of the line.
o - Open a new line below the current line and enter insert mode.
O - Open a new line above the current line and enter insert mode.
r - Replace a single character.
R - Enter replace mode.
cw - Change (replace) a word.
cc - Change (replace) an entire line.
C - Change (replace) from the cursor to the end of the line.
'c$'--Delete to the end of the line & insert the new text.
'Crtl+p'--->pool of words only command used in insert mode.
u - Undo the last change.
Ctrl+r - Redo the undone change.

Copy and Paste


--------------
yy - Yank (copy) a line.
nyy--> copies 'n' no. of lines
yw - Yank (copy) a word.
nyw--> to copy 'n' number of words
y$ - Yank (copy) to the end of the line.
y0 - Yank (copy) to the beginning of the line.
p - Paste after the cursor.
np--> paste the 'n' number of times
P - Paste before the cursor.

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.

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:

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

y - Yank (copy) the selected text.


d - Delete the selected text.
c - Change (replace) the selected text.

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'

You might also like