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

Gvim

Unix file

Uploaded by

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

Gvim

Unix file

Uploaded by

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

Vim/GVim commands

Basic Cursor Movements:

• w - Jump forward word by word.


• b - Jump backward word by word.
• B - Jump back to the beginning of the previous word.
• $ - Move to the end of the line.
• ^ - Move to the first non-blank character of the line.
• 0 - Move to the beginning of the line.
• gg - Go to the top of the file.
• G - Go to the bottom of the file.
• { - Jump backward paragraph by paragraph.
• } - Jump forward paragraph by paragraph.

Searching:

• f + p - Find the first occurrence of the character p forward.


• F + p - Find the first occurrence of the character p backward.
• fw - Find the first w character forward.
• 2fw - Find the second occurrence of w forward.

Line and Word Operations:

• 3gg - Go to the 3rd line.


• x - Delete the character under the cursor.
• u - Undo the last change.
• dw - Delete the word.
• db - Delete the previous word.
• 2dw - Delete two words.
• cw - Change (replace) the word.
• dd - Delete the current line.
• cc - Change (replace) the whole line.
• 2dd - Delete two lines.
• ct" - Change up to the next double quote character.
• ci" - Change inside double quotes.
• p - Paste after the cursor.
• P - Paste before the cursor.
• dj - Delete the current line and join the next line.

Copying and Pasting:

• yw - Copy (yank) the word.


• yy - Copy (yank) the entire line.
• y0 - Copy everything from the cursor to the beginning of the line.

Visual Mode:
• V - Enter Visual Line mode.
• v - Enter Visual mode.
• Ctrl + v - Enter Visual Block mode.
• gg + Shift + VG - Select all lines.

Highlighting and Replacing:

• gd - Go to the local declaration of the word under the cursor.


• gf - Open the file whose path is under the cursor.
• :e# - Go back to the previous file.

Multi-line and Block Operations:

• Ctrl + v -> Shift + i -> Write -> Esc - Insert text at the beginning of
multiple lines.
• 10p - Paste content 10 times.
• 14x - Delete 14 characters.

Search and Replace:

• /search_term - Search for the term (case sensitive).


• Shift + * - Highlight search for the word under the cursor.
• n - Repeat search forward.
• N - Repeat search backward.
• ?search_term - Search backward.
• :set incsearch - Incremental search.
• :set ignorecase - Ignore case during search.
• :set hlsearch - Highlight search results.
• :nohlsearch - Disable highlight search.
• /.[aeiou] - Search for any vowel.
• /\n\n - Highlight all blank lines.
• d+/fire - Delete everything before the first occurrence of "fire".
• :s/Module/module - Replace the first occurrence of "Module" with "module" in the
current line.
• :%s/Module/module - Replace "Module" with "module" globally.
• :%s/Module/module/g - Replace all occurrences of "Module" with "module" in the
entire file.

Visual Mode Replace:

• V -> % -> :s/name/replace/gc - Replace in visual mode.


• gci - Confirm and insensitive flag to search and replace line by line in visual mode.
• /[^ ]\zs( - Limit the replacement scope.
• :'<,'>s// (/ - Add space before the cursor.
• /)\ze - End highlight at the parenthesis.

Advanced Movements and Editing:


• 3L - Move 3 lines above the bottom of the window.
• 3H - Move 3 lines above the top of the window.
• :r !date - Add the current date to the file.
• :r !curl –silent URL - Paste content from a URL.
• Ctrl + w + 15 + - Adjust window size.
• :set shiftwidth=3 - Set shift width to 3 spaces.
• :set list - Display invisible characters (like spaces and tabs).
• :se nolist - Remove the display of invisible characters.
• Shift + v (Visual mode) + Shift + > - Indent the selection.
• Shift + v (Visual mode) + Shift + < - Un-indent the selection.
• :set smartindent - Enable smart indentation.
• :set softtabstop=3 - Set the soft tab stop to 3 spaces.
• Ctrl + t - Move forward.
• Ctrl + d - Move backward.

Folding:

• zf8j - Fold 8 lines.


• zo - Open folded lines.
• zc - Close folded lines.
• zd - Delete folded lines.
• zf% - Fold between matching parentheses.
• zi - Toggle folding.

Deleting Lines by Pattern:

• :v/word/d - Delete lines not containing the word.

File Operations:

• vi <filename> - Open a file.


• :w - Save the file.
• :q - Quit without saving.
• :wq - Save and quit.
• :w! - Force save a read-only file.
• :q! - Force quit without saving.
• :wq! - Force save and quit.

Editing Commands:

• i - Insert text before the cursor.


• I - Insert text at the beginning

You might also like