Back to course

Using VIM/Emacs (Introduction to Advanced Editors)

Termux Masterclass: From Zero to Linux Power User on Android

40. Using VIM/Emacs (Introduction to Advanced Editors)

While nano (Lesson 10) is easy for beginners, Vim and Emacs are the dominant, highly efficient, and programmable text editors used by power users and developers.

1. Installing Vim

Vim (Vi IMproved) is a modal editor, meaning it has different modes for insertion, navigation, and command execution.

bash $ pkg install vim

2. Basic Vim Workflow

  1. Open: vim filename.txt
  2. Normal Mode (Default): Used for navigation and commands. (Press Esc to ensure you are in Normal Mode).
    • h, j, k, l: Move cursor (left, down, up, right).
    • dd: Delete current line.
    • yy: Yank (copy) current line.
    • p: Paste.
  3. Insert Mode: Used for typing text.
    • Press i to enter Insert Mode.
    • Press Esc to return to Normal Mode.
  4. Command Mode (Saving/Exiting):
    • In Normal Mode, press : (colon).
    • :w: Write (save).
    • :q: Quit.
    • :wq: Save and quit.
    • :q!: Force quit without saving.

3. Installing Emacs

Emacs is known for its extensive features and powerful Lisp environment.

bash $ pkg install emacs

Note: Mastering Vim or Emacs requires significant dedication, but the return on investment in terms of editing speed is immense. For general Termux scripting, nano remains perfectly acceptable, but power users often graduate to Vim.