Vim (Text-Editor) Cheat Sheet for Beginners Starting from Scratch

Updated: September 19th, 2022, 09:50:10 IST
Published: September 19th, 2022
Vim (Text-Editor) Cheat Sheet for Beginners Starting from Scratch
Title: Vim (Text-Editor) Cheat Sheet for Beginners Starting from Scratch

The text editor Vim has been around for a very long time and is quite well-liked among expert users and programmers. We'll be looking at some of the most well-liked and practical Vim commands in this tutorial.

Although Vim calls itself "the ubiquitous text editor," the typical computer user is unlikely to use it frequently. However, it has a large following of devoted users and is packed with useful features. As a result, it is advisable to initially spend some time getting acquainted with the Vim editor.

Mastering Vim Commands: The Ultimate List for Beginners



vim filename.txt - opens the file to read, edit and write or exit.

:w - save the file

:q! - Quit without saving changes

:q - Quit Vim



Cursor movement
h - move cursor left
j - move cursor down
k - move cursor up
l - move cursor right

Ctrl + v - start visual block mode
Ctrl + V - visual mode to select or delete the following selected text 
(to be edited in future).

V - start linewise visual mode


Insert mode - inserting/appending text
i - insert before the cursor


Esc - exit insert mode

source:
vim . rtorr . com



Vim Commands for Cut, Copy and Paste:

Just like Find
and Replace, 
Cut, Copy and Paste
too is a common feature. 
Vim commands to work 
with cut/copy and pasting
of text can be found below:

y - Copy the selected text
p - Paste the selected text
dd - Cut the current line
yy - Copy the current line
y$ - Copy to EOL
D - Cut to EOL


Exiting
:w - write (save) the file, but don't exit
:w !sudo tee % - write out the current file using sudo
:wq or :x or ZZ - write (save) and quit
:q - quit (fails if there are unsaved changes)
:q! or ZQ - quit and throw away unsaved changes
:wqa - write (save) and quit on all tabs

Vim - the ubiquitous text editor

Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems and with Apple OS X.

Vim is rock stable and is continuously being developed to become even better. Among its features are:

  1. persistent, multi-level undo tree
  2. extensive plugin system
  3. support for hundreds of programming languages and file formats
  4. powerful search and replace
  5. integrates with many tools