Top 3 Command Line Text Editors for Linux

My Top 3 Terminal Text Editors for Linux: (vim-minimal/vim-enhanced) Vi IMproved, a programmer’s text editor
Vim is a text editor that is upwards compatible to Vi. It can be used
to edit all kinds of plain text. It is especially useful for editing


yum install vim


sudo apt install vim

vim [options] [file ..

Sample Look:
tux@freelinux:~$ vim freelinux.txt

Tip: You can run “vimtutor” to learn vim commands


Popular commands that I frequently use:

Esc – exit insert mode
i – insert before the cursor
I – insert at the beginning of the line
a – insert (append) after the cursor
A – insert (append) at the end of the line

r – replace a single character
u – undo
. – repeat last command

:q – quit (fails if there are unsaved changes)
:q! or ZQ – quit and throw away unsaved changes
:wq or : x or ZZ – write (save) and quit
:w – write (save) the file, but don’t exit

Search and replace
/pattern – search for pattern
n – repeat search in same direction
N – repeat search in opposite direction
:%s/old/new/g – replace all old with new throughout file
:%s/old/new/gc – replace all old with new throughout file but with confirmation

Cut and paste
yy – copy a line
p – put (paste) the clipboard after cursor
P – put (paste) before cursorP – put (paste) before cursor
dd – delete (cut) a line
2dd – delete (cut) 2 lines

:$ – go to last line

2. nano (Nano’s ANOther editor, an enhanced free Pico clone)
nano is a small, free and friendly editor which aims to replace Pico,the default editor included in the non-free Pine package. On top of copying Pico’s look and feel, nano also implements some missing (or disabled by default) features in Pico, such as “search and replace” and “go to line and column number”.


yum install nano


sudo apt install nano

nano [options] [[+line[,column]] file]…

Sample Look:
tux@freelinux:~$ nano freelinux.txt

Popular commands :
Ctrl+S Save current file
Ctrl+O Offer to write file (“Save as”)
Ctrl+R Insert a file into current one
Ctrl+X Close buffer, exit from nano
Ctrl+K Cut current line into cutbuffer
Ctrl+U Paste contents of cutbuffer

Cheatsheet for nano –>

Note:  In ubuntu, when you run “pico”, it will open “nano” as it is linked.
tux@labucs1:~$ ls -l /usr/bin/pico
lrwxrwxrwx 1 root root 22 Feb 28 2017 /usr/bin/pico -> /etc/alternatives/pico
tux@labucs1:~$ ls -l /etc/alternatives/pico
lrwxrwxrwx 1 root root 9 Feb 28 2017 /etc/alternatives/pico -> /bin/nano

3. emacs (GNU project Emacs editor)
GNU Emacs is a version of Emacs, written by the author of the original
(PDP-10) Emacs, Richard Stallman. The user functionality of GNU Emacs
encompasses everything other editors do, and it is easily extensible
since its editing commands are written in Lisp.


yum install emacs


sudo apt install emacs

emacs [ command-line switches ] [ files … ]

Sample Look:
tux@freelinux:~$ emacs freelinux.txt

Popular commands :
“C-x” means “press and hold the Control key and then press and release the “x” key

C-x C-c – quit
C-x C-s – save buffer
C-x C-f – open file
C-g – cancel
C-s – search
C-o – insert newline after cursor

Cheatsheet for emacs –>

There’s few honorable mentions, but installation may not be straightforward, comparing to those 3 above that can be installed via “apt install” or “yum install”.

  • neovim
  • micro
  • ne (nice editor)

About the author

Free Linux

View all posts

Leave a Reply