My Top 3 Terminal Text Editors for Linux:
1.vi/vim (vim-minimal/vim-enhanced) Vi IMproved, a programmer’s text editor
DESCRIPTION
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
programs.
Redhat-based/CentOS:
yum install vim
Debian-based/Ubuntu:
sudo apt install vim
Syntax:
vim [options] [file ..
Sample Look:
tux@freelinux:~$ vim freelinux.txt
Tip: You can run “vimtutor” to learn vim commands
vimtutor
Popular commands that I frequently use:
Inserting/Appending
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
Editing
r – replace a single character
u – undo
. – repeat last command
Exiting
: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
Additional:
:$ – go to last line
2. nano (Nano’s ANOther editor, an enhanced free Pico clone)
DESCRIPTION
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”.
Redhat-based/CentOS:
yum install nano
Debian-based/Ubuntu:
sudo apt install nano
Syntax:
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 –> https://www.nano-editor.org/dist/latest/cheatsheet.html
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)
DESCRIPTION
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.
Redhat-based/CentOS:
yum install emacs
Debian-based/Ubuntu:
sudo apt install emacs
Syntax:
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 –> https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf
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)