Tags:
create new tag
, view all tags
See BLT and AboutThesePages.

vi: a powerful command line text editor included in almost all unix/linux distributions

vi is the only editor available in some circumstances (like while running a rescue disk) so it is important to know a few things about vi:

  • to quit -- :w to save, and :q to quit -- often you will need to hit <escape> first to get to command mode
  • to enter text -- :i to get into insert mode -- to get back to command mode hit <escape>

See:

Resources

  • VI Commands Cheat Sheets -- link provided by (and conversion to HTML by) J. Craig Woods
  • vim comes with a tutor -- type vimtutor (at a command line)
  • Editor's Desk; Steve Litt; (c) 2001 -- haven't read, but I've read some other stuff by Steve that, IIRC, I liked

Some Specific Tasks

Set Word Wrap

from dfox on 2002-04-14:

<esc>se wm=6

"That's for setting the wrap margin. I should point out that it should be set to the number of characters from the right margin. I.e., if you set wm to 72, you'll end up with most of your words on a new line."

Reformat a paragraph

from dfox on 2002-04-14:

"If you want to do more complicated formatting within vi, you can use the Q command (at least in vim). Use the Q followed by a movement command, such as } for paragraph, and voila, your paragraph will be formatted for the current wrap margin setting. It won't justify though, but it's good for things like when people can't use their editors and their text is turned into one long line etc. More complicated things can be done if you pipe your text through to 'fmt' which can even justify the text."

Recording Mode

Actually, this relates to vim rather than vi.

from: http://www.vim.org/html/repeat.html#q -- suggested by mike (mgrello@scPLEASENOSPAM.rr.com) after I posted that I had accidentally got into record mode and couldn't find my way out:

q{0-9a-zA-Z"} Record typed characters into register {0-9a-zA-Z"} (uppercase to append). The 'q' command is disabled while executing a register, and it doesn't work inside a mapping. {Vi: no recording}

q Stops recording. (Implementation note: The 'q' that stops recording is not stored in the register, unless it was the result of a mapping) {Vi: no recording}

All commands and command sequences can be repeated by putting them in a named register and then executing it. There are two ways to get the commands in the register: - Use the record command "q". You type the commands once, and while they are being executed they are stored in a register. Easy, because you can see what you are doing. If you make a mistake, "p"ut the register into the file, edit the command sequence, and then delete it into the register again. You can continue recording by appending to the register (use an uppercase letter).

So, it appears, according to this that you turn recording on by hitting q and then a register to put it in, and turn it off by just typing q.

Contributors

  • HaroldSharp - 01 Feb 2002
  • RandyKramer - 06 Apr 2002
  • <If you edit this page, add your name here, move this to the next line>
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2003-09-07 - AnitaLewis
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look