History Report a problem
Article Edit this page Discussion

Tutorial Commands

From Vim Tips Wiki

Jump to: navigation, search

Proposed new tip

Please do not discuss this tip on this page, and do not edit the talk (discussion) page.

All discussion should take place on the proposed new tips page, where we will decide whether to keep this as a new tip, or whether to merge it into an existing tip.


Created: February 16, 2008 Complexity: basic Author: Metacosm Version: 7.0


  • hands on the home row asdf hjkl
  • 3 modes, command mode (hit esc to return to it), insert mode (hit i to enter it) and visual mode (hit v to enter it)
  • hjkl move in command mode, h is left and moves left, l is right and moves right, j looks like a down arrow and moves down, k moves up.
  • w moves one word forward 3w moves three words forward, b moves one word backward, 3b moves three words backwards
  • gg moves to beginning of file, G (this is shift-g*) moves to end of file, number followed by shift-g moves to that line number 374(shift-g) will move to line 374
  • more on moving, 8k moves eight lines up, 5j moves five lines down, 4l moves four characters right, 23h moves 23 characters left
  • in command mode :w to save, :q to quit, :w! to overwrite, :q! to quit w/o saving, :wq to save and quit, :wq! to overwrite and quit, :e file to open "file"
  • ! ignore any editor warnings
  • : opens command line which is used for many things other than just saving, opening and quitting
  • objects and actions: at beginning of word: d2w (action)(times)(object) (delete)(2)(words forward) this deletes including the trailing space need to leave it? use de this deletes one word and leaves the trailing space
  • d2b (delete)(2)(words backward)
  • hjkl are also objects! example: d3l (delete)(3)(left), for hl we count individual characters, not words, for jk we count individual lines, d3k delete 4 lines up (3 plus current)
  • cw (change)(word) learned something before? yes! (times)!! c3w (change)(3)(words)
  • cb (change)(word backward) c3b (change)(3)(words backwards)
  • didn't catch why c and d ? look again d3w then check mode, ok, c3w*, now check mode, yes, indeed
  • with all this power to change and delete you need u to undo and control-r to redo, infinitely
  • autocompletion: "whatchamacallit" need to type it again? wh(Control-p) will find previous word that starts with "wh" control-p control-n cycle through matches in (p)revious and (n)ext order
  • VISUAL MODE: v3w (visual select)(3)(words) repeat with b and hjkl*
  • what to do with selection: y will "yank" (ie copy selection) p will "put" (ie insert) at new location, use y in visual mode and p in normal mode
  • more ways to enter insert mode: i a o I A O*
    • i insert at current location
    • a insert after current location
    • o insert line below current line
    • I insert AT START of current line
    • A insert AFTER END of current line
    • O insert line ABOVE current line.
  • convenience commands: dd delete current line, yy yank current line
  • Searching: /regularexpression to search forward, ?regularexpression search backward
  • as before we can combine objects for more y/) will yank everything to NEXT parens (or whatever you search for) while y?) will yank everything up to the LAST parens

[edit] Comments

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Godzilla
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Tutorial Commands"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.