Learning to install Vim and understanding modes of Vim

By | January 17, 2018

Sponsored

The Vim editor is a popular Free and Open Source text editor. It is an improved version of the vi text editor. Vim is extremely popular among the Linux, macOS and Unix-like system users. this one has many commands that help you to edit your text files efficiently. It comes with a pretty extensive built-in manual as well.

Here we discuss mainly two topics

  • How to install Vim
  • Understanding modes of Vim (command modes and insert modes)

How to install Vim

  • Debian and other Debian-based distros like Ubuntu, Linux Mint:
    sudo apt-get install vim
  • Fedora:
    sudo dnf install vim
  • Arch Linux:
    sudo pacman -S vim

 

For more details

Sponsored

screenshot vim

Learning vim

 

Understanding modes of Vim (command modes and insert modes)

In the command mode, a user can move around the file, delete text, etc. In the insert mode, a user can insert text.

Changing mode from one to another:

  • From command mode to insert mode type a/A/i/I/o/O
  • From insert mode to command mode type Esc

Some useful commands for VIM

aAppend text following current cursor position
Append text to the end of current line
iInsert text before the current cursor position
IInsert text at the beginning of the cursor line
oOpen up a new line following the current line and add text there
O Open up a new line in front of the current line and add text there

The following commands are used only in the commands mode.

Cursor Movement Commands

hMoves the cursor one character to the left
lMoves the cursor one character to the right
kMoves the cursor up one line
jMoves the cursor down one line
nG or :nCursor goes to the specified (n) line (eg. 10G goes to line 10)
^F (CTRl F)Forward screenful
^BBackward screenful
^fOne page forward
^bOne page backward
^UUp half screenful
^DDown half screenful
  $Move cursor to the end of current line

 

Home

More about Vim:

Vim is the editor of choice for many developers and power users. It’s a “modal” text editor based on the vi editor written by Bill Joy in the 1970s for a version of UNIX. It inherits the key bindings of vi, but also adds a great deal of functionality and extensibility that are missing from the original vi.

What do we mean by modal? When you’re using most word processors and text editors, the alphanumeric keys (i.e., a through z, 1 through 9) are only used to input those characters unless they’re modified by a control key. In Vim, the mode that the editor is in determines whether the alphanumeric keys will input those characters or move the cursor through the document.In Vim, you can save a file without your hands leaving the keyboard, and sometimes without even leaving the home keys. From Vim’s insert mode, hit Escape and then :w. That’s all. More on that later.

 

 

Sponsored