Nano vs VIM editor – What’s the difference between nano and vim editors?

Nano Editor Vs Vim

Vim and Nano are two of the commonly used editors available on Linux. Both the editors differ a lot in the way they operate. Nano is simple to use and easy to master while Vim is powerful and tough to master.

  • Vim is a mode based text editor while Nano is modeless. Mode based editor means that you need to enter INSERT mode before you can write text to the file.
  • Nano is also a WYSIWYG command-line text editor. WYSIWYG means What You See Is What You Get.
  • Nano is an improvement over the Pico text editor, whereas Vim is an improved version of the Vi editor.
  • Nano is perfect for a newcomer to get started within no time, whereas Vim is for slightly experienced Linux users.

You can learn about Nano editor in detail by reading this tutorial.

To learn about Vim Editor in detail, read this tutorial.

This tutorial will go over the main point of differences between Vim editor and Nano editor.

Difference Between the Interface of VIM and Nano Editor

The window that you see when you open the two editors differs hugely. Nano editor is more friendly in its appearance as compared to Vim editor.

Nano editor

When you open the Nano editor the screen looks like as shown.

Nano Screen
Nano Screen

Vim editor

When you open Vim editor, the screen looks like as follows :

Nano Editor 3

For a newbie the Nano editor looks a lot easier to use as it has all the shortcuts at the bottom of the screen.

Nano Bottom Part 1 1

Modes in Vim

As already mentioned, Vim is a mode based editor. The different modes available in Vim are as follows :

  • Normal (Default): For navigation 
  • Insert: For inserting and modifying text
  • Command: For Operations like saving, exiting, etc.

By default, you are in Normal mode. In normal mode, you can just view your text and navigate through it. Insert mode allows you to make changes to your code. The command mode is for specifying commands to exit, save your work, and perform other operations.

To enter command line mode press colon (:).

To enter insert mode press ‘i’.

To exit a mode press ESC.

Nano editor does not have any modes, therefore it is considered easier to use.

Differences in Navigation Between the VIM and Nano Editor

The navigation shortcuts are different for the two editors.

Nano Editor

Navigation shortcuts for Nano editor are :

  • Ctrl+F: move the cursor forward.
  • Ctrl+B: move the cursor backward.
  • Ctrl+Space: move forward one word.
  • Alt+Space: move backward one word.
  • Ctrl+V: move to the next page.
  • Ctrl+Y: move to the previous page.
  • Ctrl+N: move to the next line. 
  • Ctrl+P: move to the previous line

Vim Editor

Navigation shortcuts for Vim editor are :

  • h: Move the cursor to left by one position.
  • I: Move the cursor to right by one position.
  • j: Move the cursor to downward direction by one line.
  • k: Move the cursor to upward direction by one line.

You can also use your keyboard arrow keys instead of the letters.

Differences in how to save and exit in Nano and VIM Editor

The process to save and exit is different for the two editors.

Nano Editor

To save and exit in nano editor use the shortcut Ctrl + X. Nano editor will now ask whether you want to save your changes.

Prompt 1

Press Y and save your file.

Vim Editor

To save your changes in Vim editor you have to be in command line mode. The command for save and exit is :wq followed by Enter.

:wq [enter] 

Searching Text Nano vs VIM Editor

Both the editor provide the option to search for text in the file.

Nano editor

To search for text in nano editor use Ctrl + W.

Search 1

This is where you can enter the text to search for. To move among occurrences of the word use  Alt+W.

Vim editor

In Vim editor to search in the file you must be in command line mode. So start by pressing colon (:).

To search for a word use forward slash followed by the word to search followed by enter.

/{word-to-be-searched} [enter] 

Which of the two is better?

There is no straight forward answer to this question. Vim is better at performing complex edits but it is difficult to expert. Nano editor has no learning curve but is inefficient at performing complex edits.

The answer to the question depends on your needs. If you are looking for a simple text editor then you should go with nano editor. However, if you are looking for a text editor to edit code and perform complex text edits, you should go with Vim. In fact, Vim is a must for Linux system administrators.

Conclusion

This tutorial was about the differences between Vim editor and Nano editor. Both the editors have their own purpose and use cases. A third text editor that is as advanced as Vim and as simple as Nano is Emacs.