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
- Open:
vim filename.txt - Normal Mode (Default): Used for navigation and commands. (Press
Escto 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.
- Insert Mode: Used for typing text.
- Press
ito enter Insert Mode. - Press
Escto return to Normal Mode.
- Press
- Command Mode (Saving/Exiting):
- In Normal Mode, press
:(colon). :w: Write (save).:q: Quit.:wq: Save and quit.:q!: Force quit without saving.
- In Normal Mode, press
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.