Customizing Your Editor

If you are new to command-line editors, you may feel they are difficult to use. Indeed, it could be true if you use them without customization. But, if you customize them for yourself, they can become your best friend.

Try and choose one editor

There are various editors usable on Linux. There are many others, but these four are among the most popular. Please try them and find the best one for you.

Editor

Description

nano

simple, but less customizable.

vim/neovim

complex, but highly customizable.

emacs

complex too, but highly customizable.

micro

simple and easier than nano. Mouse cursor is supported.

Note

neovim is a 2014 fork of vim that enhances the codebase and introduces new features.

We recommend neovim but it can be a bit difficult to use at first. Read the small description below to have basic knowledge about it. emacs is also a good choice and is more intuitive than vim/neovim.

Getting started on Ubuntu

nano:

$ sudo apt install nano

nano Command Manual

vim/neovim:

$ sudo apt install neovim # or sudo apt install vim if you prefer the older version

To open a file with neovim, use:

$ nvim FILE_NAME

In the following, we will use vim to refer to both vim and neovim, as they are very similar.

vim has two main “modes”: NORMAL mode (aka COMMAND mode) and INSERT mode. In NORMAL mode, pressing keys on your keyboard will execute commands (like undo u, redo r, find and replace :%s/foo/bar/g, quit :q, etc.). In INSERT mode, you type text. There is a third mode, VISUAL mode, that is used to highlight and edit text in bulk.

To go into INSERT mode from NORMAL mode, you type i. To go back to COMMAND mode, you type the esc key. vim starts out in NORMAL mode.

The following commands are useful:

  • :w saves the current changes to a file. If you don’t specify a name, changes will be saved to the current file. If you would like to save the file under a different name, specify a filename (:w file).

  • :q quits vim. If you have unsaved changes (or cannot quit smoothly for other reasons), you will have an error message.

  • :q! forces vim to quit (without saving changes).

  • :wq saves and quit.

We strongly recommend that you follow the following tutorials:

emacs:

$ sudo apt install emacs

A guided tour of Emacs

micro:

$ sudo apt install micro

Tutorial

Customize your editor

Please choose an editor and customize it. vim, emacs and micro allow us to customize appearance. vim and emacs support auto-completion if properly set up.