0% found this document useful (0 votes)
13 views4 pages

Gvim Commands Notes (1)

The document provides installation instructions for Vim and GVim on Debian and Redhat-based operating systems. It details various GVim commands, modes, file management, navigation, and advanced features like macros. Additionally, it covers search and replace functionalities, copy and paste commands, and window management techniques within the GVim interface.
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)
13 views4 pages

Gvim Commands Notes (1)

The document provides installation instructions for Vim and GVim on Debian and Redhat-based operating systems. It details various GVim commands, modes, file management, navigation, and advanced features like macros. Additionally, it covers search and replace functionalities, copy and paste commands, and window management techniques within the GVim interface.
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/ 4

For debian like OS(i.

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

To open file there are two ways


1.vertical split the window
:vspl <filename.ext>(.txt,.doc,.v,.py)
2.horizatal split the window (default)
:spl <filename.ext>
*create a file outside the gvim and open with gvim
*open gvim and when you are saving the file give a name to that file.

How save a file?


*The commands used to save a file
:w --write one file
:wa --write all files
:w with<filename>
Note:if you find a [+] sign after the filename,this file not saved.

How to close/quit the file


*the commands used to quit a file
:q quit
:wq save and quit
:q! quit without saving
:wqa save and quit all
:qa quit all

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.
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

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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy