User Tools

Site Tools


Table of Contents

Editing files

To edit a file from the Unix CLI, you can use nano or vim.


nano myfile.txt

Nano uses the Ctrl-key for special commands. The interface tells you which shortcut does what, where ^X means CtrlX

Shortcut Command
^O CtrlO save file
^X CtrlX exit; quit
^W CtrlW search


vim myfile.txt

Vim has two modes, and starts in Command mode by default.

Command mode
Shortcut Command
iinsert; go to editing mode
wjump to next word
dddelete a line
ppaste deleted line
/foosearch for text foo
/repeat previous search
:syntax onenable syntax colors
:wwrite / save file
:wqwrite and quit
:wq!force write and quit
Editing mode
Escgo to command mode
wiki/unix/edit.txt · Last modified: 2019/04/25 15:23 (external edit)