Editing Files from the Command Line

nano

  • Very simple and easy
  • to open a file: nano <file-name>
  • Ctrl + O: Write changes
  • Ctrl + K: Cut current line
  • Ctrl + U: Uncut and past at current cursor
  • Ctrl + W: Search for keyword
  • Ctrl + X: Exit

vi

  • Very fast and powerful, but steep learning curve
  • open file: vi <file-name>
  • I Get into Insert-text mode
  • Esc Get into Command mode
  • DD delete line
  • YY copy line
  • P Paste clipboard contents
  • X remove content under cursor
  • :w write to disk
  • :q! exit without writing
  • :wq! Save file and quit

Relevant Note(s): Linux Basics