Linux Tutorials

Text Editors on Linux

Overview of the most common editors. Installation, basic usage, configuration and when to use which editor.

Nano

Beginner-friendly terminal editor. Simple shortcuts, ideal for quick changes on servers.

Install

sudo apt update
sudo apt install nano

Open a file

nano /etc/hosts

Basics

  • Ctrl+O save, Ctrl+X exit
  • Ctrl+W search, Ctrl+\ replace
  • Ctrl+K cut line, Ctrl+U paste
  • Alt+G go to line, Alt+A mark, Alt+6 copy

Config

/etc/nanorc
~/.nanorc

When to use

Best for beginners and quick edits on servers or config files.

Vim

Modal editor focused on speed and keyboard efficiency. Great once you learn the modes and motions.

Modes

  • Normal — navigate and run commands. <Esc> to enter.
  • Insert — type text. Enter from Normal with i (insert before), a (after), I (bol), A (eol), o/O (new line).
  • Visual — select text. v (char), V (line), Ctrl+v (block).
  • Replace — overwrite characters. R.
  • Command-line — ex commands and search. :, /, ?.

Essential motions

h j k l        move left/down/up/right
w b e         word forward/back/end
0 ^ $         start of line / first nonblank / end of line
gg G          top / bottom
} {           next / previous paragraph or block
%             jump to matching (), {}, []

Editing basics

x   delete char        dd    delete line
dw  delete word        D     delete to end of line
u   undo               Ctrl+r redo
y   yank (copy)        p     paste after     P paste before
r   replace one char   J     join with next line
.   repeat last change

Visual selections

v ... y      yank selection
v ... d      delete selection
Ctrl+v       block select (use I/A to insert at column across lines)

Search and replace

/text           forward search (n next, N prev)
/foo\|bar       search alternation
:%s/old/new/g   replace all in file
:%s/old/new/gc  confirm each
:noh            clear search highlight

Buffers, windows, tabs

:e file         edit file (new buffer)
:bn  :bp        next / previous buffer
:bd             delete buffer
:split          horizontal split        :vsplit vertical split
Ctrl+w h/j/k/l  move between splits
:tabnew         new tab
gt  gT          next / previous tab

Save & quit

:w              write file
:q              quit
:wq or :x       write and quit
:q!             quit without saving

Registers and macros

"ayy            yank line to register a
"ap             paste from register a
qaq ... q       record macro into a (q to stop)
@a              run macro a      @@ repeat last macro

Indenting & formatting

>>  indent line           <<  outdent line
=G   reindent to end        =a{ reindent a block
gwip reflow paragraph (wrap)

Minimal ~/.vimrc

" ~/.vimrc
set nocompatible
set number relativenumber
set tabstop=4 shiftwidth=4 expandtab
set ignorecase smartcase incsearch hlsearch
set clipboard=unnamedplus
syntax on
filetype plugin indent on

Plugins (vim-plug)

" Install vim-plug: https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
call plug#end()
" :PlugInstall to install

Handy tricks

  • ci(, ci", ci' — change inside matching pair/quotes.
  • diw, ciw — delete/change inner word.
  • gv — reselect last visual selection.
  • "_d — delete to black-hole register (keeps clipboard).
  • :set spell and ]s/[s to navigate spelling.
  • :terminal opens a terminal in a split (Neovim) or with plugin in Vim 8.

Install

# Ubuntu/Debian
sudo apt install vim

# Fedora
sudo dnf install vim

# Arch
sudo pacman -S vim

Neovim

Modern fork of Vim. Cleaner codebase, Lua scripting, async plugins.

Install

sudo apt install neovim

Open a file

nvim file.txt

Basics

  • Compatible with Vim commands and keybindings
  • Supports Lua for configuration and plugins
  • Async job control for LSP and autocompletion

Config

~/.config/nvim/init.vim
~/.config/nvim/init.lua

When to use

Best for developers wanting Vim features plus modern plugin ecosystem and performance.

Emacs

Highly extensible editor with its own Lisp system. More than an editor: full environment.

Install

sudo apt install emacs

Open a file

emacs file.txt

Basics

  • C-x C-s save, C-x C-c quit
  • C-x C-f open file, C-x b switch buffer
  • M-x run extended commands

Config

~/.emacs
~/.emacs.d/init.el

When to use

Best for power users who want an editor that can also act as IDE, mail client, or even window manager.

Visual Studio Code

Modern GUI editor with strong ecosystem. Great for beginners and advanced devs.

Install

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt update
sudo apt install code

Open a file or folder

code file.txt
code project/

Basics

  • Integrated terminal and debugger
  • Extensions for languages, themes, linters
  • Command palette (Ctrl+Shift+P) for everything

Config

~/.config/Code/User/settings.json

When to use

Best for projects requiring GUI, debugging, Git integration and quick plugin setup.