Follow Slashdot stories on Twitter


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×
User Journal

Journal Journal: Unicode 1

Let's test Slashdot Unicode support: ó

User Journal

Journal Journal: vi Reference

vi is a simple screen-oriented text editor from UNIX. Many clones of vi exist throughout the software world. It is difficult to learn how to use vi because it behaves differently from most other text editors. However, once you learn how to use vi, it is an extremely efficient text editor, and so you'll have vi x.txt ingrained in your frequently-used-commands muscle memory.

Here is how I typically use vi:

  • To create a new file or read an existing file, vi x.txt, where x.txt is the filename to edit.
  • vi starts out in command mode. With an existing file, use the arrow keys, Page Up/Page Down, HJKL, or ^f ^b ^d ^u to navigate. Or use the old ex commands -- for example, :123 where 123 is the line number to jump to. Search for strings using / and then a regex. Press enter to find next occurrence.
  • To start typing text, pressing i or Insert switches to insert mode. Type away and press Esc when done to switch back to command mode. Backspace works unless terminal settings are haywire. Backspace at the beginning of a line probably doesn't do anything... it's the vi way. Delete may not work properly, if at all. You may need to experiment with it. Otherwise, switch to command mode and press x to do a forward delete.
  • To yank out an entire line, press dd.
  • Cut and paste with mouse. Or, see how to do it properly and also more good esoteric vi commands with this vi cheat sheet.
  • To quit: :q! to save without changes, otherwise most vi implementations support ZZ to keep changes. Fallback: :wq or :w. If you back up everything all the time, :q! is merely a convenience.

Slashdot Top Deals

The number of computer scientists in a room is inversely proportional to the number of bugs in their code.