User login

Vi Text Editor

The Vi (and its successor Vim, for Vi improved) text editor for Unix, GNU-Linux, and Mac OS X systems is a way to edit text files, including configuration, PHP, or HTML documents, through the command line interface. This includes, of course, using SSH to connect to a server.

To use it with even a minimum of efficiency, though, you need to know a fair number of its cheat codes– err, keyboard shortcuts.

These are resources the Agaric Designe Collective found useful (when we started out, now of course we can type sonnets and ASCII art on the command line in our sleep).

vi file.txt edits a file or creates a file and starts editing.

In command mode:

k One line up
j One line down
^ Beginning of current line
$ End of current line

dd Deletes current line
5dd Deletes five lines (pick your number)...
dw Deletes current word
7dw Delete seven words...
u Undoes last change

You can enter edit mode by pressing i (note that you can do enough editing to obliterate your document in command mode, but i lets you insert text).

These and more, and more detail, found at http://www.ms.washington.edu/help/editors/vi.html

and http://www.uic.edu/depts/accc/software/unixgeneral/vi101.html

Comments

To go to the end of the file

To go to the end of the file in vi, simply press the letter

G

And yes,

To use vim to delete to the end of a file,

dG

does it.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.