Create, View and Edit Text Files
Linux File Editors
● Text editing tools used for creating, modifying, and viewing
text files within the Linux
● Various types of editors used in linux are Vi/Vim, Emacs, and
Nano
VI/Vim editor:
● Features include :
○ Text Manipulation
○ Text Replacement
○ File Navigation
○ String Search & Replace
○ Cut & Paste
Vi Editor
Modes in vi editor
Command mode
In command mode you will see the filename in the
bottom
Insert mode
● In insert mode you will see ‘--INSERT--’ written in bottom .
● Now , you can add or delete text in file
Execution mode
● Enter execution mode by press Shift + :
● In this, you can save changes, quit the editor, or execute various
commands.
● For e.g- To save type :wq! And press Enter
Search
● In vi editor, press "/" followed by the keyword to search forward.
● To search backward, press "?" followed by the keyword.
Forward search Backward search
Important keys
● i -> Enter insert mode before the cursor
● x ->Delete character under the cursor
● Esc -> Exit insert mode
● dd -> Delete the current line
● u -> Undo the last change
● Ctrl-r -> Redo the last undo
● :/pattern -> Search for a pattern
● :w -> Write (save) the file
● :q -> Quit the editor
● :q! -> Quit without saving changes
● :wq -> Write and quit
Various other editors used in Linux
● Emacs: Highly extensible and customizable text editor with powerful
features, including code editing, macros, and integration with other
tools
● Nano: User-friendly, simple text editor that is ideal for quick edits and
easy navigation, making it a good choice for beginners
Emacs editor
Nano editor