Vim in Linux: A beginners guide

'Vim is a top favourite among many programmers because of its array of salient features such as mouse support, syntax highlighting, new editing commands.'

Share Facebook Twitter Linkedin

A Beginner’s Guide to Start Using Vim

Vim stands for Vi IMproved and is a rich text editor specifically tailored for Linux systems. Users use this versatile tool to edit files directly from the command shell, making editing and working on configuration files become easier to manage. Vim is a top favourite among many programmers because of its array of salient features such as mouse support, syntax highlighting, new editing commands.

It also comes with an aesthetic visual mode, graphical versions, and extensions for ex commands that make working on files become such an exciting and fun experience.  Vim’s functionalities and user interface are easily customisation, depending on the specific effects a user would like to achieve. Following is a simple guide to start using Vim for beginner programmers in Unix/Linux environment.


To install Vim on any version of Ubuntu, insert the command sudo apt-get install vim, and to add new plugins, use the command sudo apt-cache search vim. This command should provide you with an array of different packages tailor-made for Vim, along with a series of add-on managers and programming languages that match your preference.

Next, enter the command Vim in the terminal to display a lovely “welcome screen”. For users who are new to Vim, they may find it difficult to exit from their text editor since its shortcuts are different from other systems. In order to start using any menu-type function, like exit or save, every command you wish to execute should begin with a colon every time (:). That means an exit command should be :q, and a saving command should be :w.

For those who’d like to quit without saving, a person should simply enter the command :q!. Also if you’d like to save and quit a file simultaneously, all you have to do is initiate the command :wq and the command would be successful.

After this stage, close Vim and open it on a new sample text file. Simply insert a unique name of the new text file after the command vim [text file name]. It’s important to note that at this stage, you’re in visual mode, so don’t be confused.

Installation part 2

Although the visual mode may look quite similar to Vim, the visual mode is specially designed for displaying text and using some commands while Vim supports both visual and editing capabilities. To switch to editing mode, push the button i to insert and the button a to add new text. To switch back to visual mode and retrieve all the menu-type functions, push the “Escape” key button.

In most programming languages, the difference between “insertion” and “addition” simply means that you’d like the text you’re typing to appear before or after the cursor in visual mode. As a rule of thumb, make a habit of using “add” at the end of each line and “insert” in other different cases.

Moving the cursor within a text for both visual and editing mode is easy, just play around with the keyboard arrows to drag the cursor to any point on the screen. Many experienced programmers use the buttons l for right, h for left, k for up, and j for down.

Understanding a few Basic Commands

Now that you know everything about installing Vim on Ubuntu and switching your text editor from visual to editing mode, here are some other additional commands you can employ in visual mode.

  • u: to undo an action
  • x: to erase a character
  • yw: to copy a word
  • yy: to copy a line
  • dw: to erase a word
  • dd: to erase a line
  • r: to replace a letter
  • e: to shift to the next word much faster than relying on arrow keys
  • P: to the previously erased or copied word or line

There are still a few more commands you can use, but the ones mentioned above should allow for an easy jumpstart and allow you to begin working on Vim like a pro.

Advanced Commands

After you’ve finally mastered and become familiar with some of the basic commands listed above, here are a few advanced and useful commands frequently used by many experienced programmers in Vim.

  • Ctrl+Shift+C and Ctrl+Shift+V: to copy and paste text in a terminal
  • /searched_word: to search for a word or phrase within a text
  • :vsp name_of_a_text_file: this function splits the screen vertically
  • :sp name_of_a_text_file: this function splits the screen in half horizontally, while also displaying the new text file in the other half
  • Ctrl+w allows users to switch between the left and right window
  • :!name_of_a_command: starts a command external to vim directly into a user’s shell without closing the editor


Above are some of the most useful and frequently used commands in Vim, and how you can install the text editor seamlessly on Ubuntu. Following this guide, you’ll find it easy to edit files directly from the command shell and improve your programming skills to a whole new level.


Leave your comment

Your email address will not be published. Required fields are marked *