DEV Community

Aryan Vaishnani
Aryan Vaishnani

Posted on

Text Editors (vi/vim, nano)

Text editors are used to:

  1. Create files
  2. Edit configuration files
  3. Write scripts
  4. Modify code
  5. Manage server settings

Most common Linux terminal editors:

  1. vi
  2. vim
  3. nano

1. vi Editor

What is vi?

vi stands for Visual Editor.

It is one of the oldest and most important Unix text editors.

Available in almost every Linux system.

Features of vi

  1. Lightweight
  2. Fast
  3. Keyboard-driven
  4. Works in minimal systems
  5. Available in recovery mode environments

Open File in vi

vi filename.txt

Example:

vi nginx.conf

Important Navigation Keys

Key Action
h Left
l Right
k Up
j Down

Useful vi Commands

Command Purpose
dd Delete line
yy Copy line
p Paste
/word Search word
u Undo

2. vim Editor

What is vim?

vim = Vi Improved

Vim

Advanced version of vi.

Features of vim

  1. Syntax highlighting
  2. Better navigation
  3. Plugins support
  4. Undo/redo improvements
  5. Better scripting support
  6. Search highlighting

Open File in vim

vim filename.txt

Install vim

Ubuntu/Debian

sudo apt install vim -y

Important vim Features

Syntax Highlighting

Useful for:

  1. Python
  2. YAML
  3. Shell scripts
  4. JSON
  5. Kubernetes manifests

Enable Line Numbers

Inside vim:

:set number

Search Text

/nginx

Replace Text

:%s/old/new/g

Real-World Usage

Edit Docker Compose

vim docker-compose.yml

Edit Bash Script

vim backup.sh

Why vim is Popular in DevOps

  1. Fast remote editing
  2. Works over SSH
  3. Efficient keyboard shortcuts
  4. Available on most Linux servers
  5. Handles huge files efficiently

3. nano Editor

What is nano?

nano is a simple beginner-friendly terminal editor.

GNU nano

Features of nano

  1. Easy to learn
  2. On-screen shortcuts
  3. Beginner friendly
  4. Simple editing

Open File in nano

nano filename.txt

Example:

nano notes.txt

Important nano Shortcuts

Shortcut Purpose
CTRL + O Save
CTRL + X Exit
CTRL + K Cut line
CTRL + U Paste
CTRL + W Search

Real-World Usage

Edit Config Quickly

nano .env

Edit Small Scripts

nano deploy.sh

Top comments (0)