8.  Nitty-gritty details

8.1.  Line representation in the display

      The editor folds long logical lines onto many physical lines in the display. Commands which advance lines advance logical lines and will skip over all the segments of a line in one motion. The command | moves the cursor to a specific column, and may be useful for getting near the middle of a long line to split it in half. Try 80| on a line which is more than 80 columns long.**

      The editor only puts full lines on the display; if there is not enough room on the display to fit a logical line, the editor leaves the physical line empty, placing only an @ on the line as a place holder. When you delete lines on a dumb terminal, the editor will often just clear the lines to @ to save time (rather than rewriting the rest of the screen.) You can always maximize the information on the screen by giving the ^R command.

      If you wish, you can have the editor place line numbers before each line on the display. Give the command :se nuCR to enable this, and the command :se nonuCR to turn it off. You can have tabs represented as ^I and the ends of lines indicated with `$' by giving the command :se listCR; :se nolistCR turns this off.

      Finally, lines consisting of only the character `~' are displayed when the last line in the file is in the middle of the screen. These represent physical lines which are past the logical end of file.

8.2.  Counts

      Most vi commands will use a preceding count to affect their behavior in some way. The following table gives the common ways in which the counts are used:

new window size      :  /  ?  [[  ]]  `  
scroll amount        ^D  ^U
line/column number   z  G  |
repeat effect        most of the rest

      The editor maintains a notion of the current default window size. On terminals which run at speeds greater than 1200 baud the editor uses the full terminal screen. On terminals which are slower than 1200 baud (most dialup lines are in this group) the editor uses 8 lines as the default window size. At 1200 baud the default is 16 lines.

      This size is the size used when the editor clears and refills the screen after a search or other motion moves far from the edge of the current window. The commands which take a new window size as count all often cause the screen to be redrawn. If you anticipate this, but do not need as large a window as you are currently using, you may wish to change the screen size by specifying the new size before these commands. In any case, the number of lines used on the screen will expand if you move off the top with a - or similar command or off the bottom with a command such as RETURN or ^D. The window will revert to the last specified size the next time it is cleared and refilled.**

      The scroll commands ^D and ^U likewise remember the amount of scroll last specified, using half the basic window size initially. The simple insert commands use a count to specify a repetition of the inserted text. Thus 10a+----ESC will insert a grid-like string of text. A few commands also use a preceding count as a line or column number.

      Except for a few commands which ignore any counts (such as ^R), the rest of the editor commands use a count to indicate a simple repetition of their effect. Thus 5w advances five words on the current line, while 5RETURN advances five lines. A very useful instance of a count as a repetition is a count given to the . command, which repeats the last changing command. If you do dw and then 3., you will delete first one and then three words. You can then delete two more words with 2..

8.3.  More file manipulation commands

      The following table lists the file manipulation commands which you can use when you are in vi.

:w           write back changes
:wq          write and quit
:x           write (if necessary) and quit (same as ZZ).
:e name      edit file name
:e!          reedit, discarding changes
:e + name    edit, starting at end
:e +n        edit, starting at line n
:e #         edit alternate file
:w name      write file name
:w! name     overwrite file name
:x,yw name   write lines x through y to name
:r name      read file name into buffer
:r !cmd      read output of cmd into buffer
:n           edit next file in argument list
:n!          edit next file, discarding changes to current
:n args      specify new argument list
:ta tag      edit file containing tag tag, at tag
All of these commands are followed by a CR or ESC. The most basic commands are :w and :e. A normal editing session on a single file will end with a ZZ command. If you are editing for a long period of time you can give :w commands occasionally after major amounts of editing, and then finish with a ZZ. When you edit more than one file, you can finish with one with a :w and start editing a new file by giving a :e command, or set autowrite and use :n <file>.

      If you make changes to the editor's copy of a file, but do not wish to write them back, then you must give an ! after the command you would otherwise use; this forces the editor to discard any changes you have made. Use this carefully.

      The :e command can be given a + argument to start at the end of the file, or a +n argument to start at line n. In actuality, n may be any editor command not containing a space, usefully a scan like +/pat or +?pat. In forming new names to the e command, you can use the character % which is replaced by the current file name, or the character # which is replaced by the alternate file name. The alternate file name is generally the last name you typed other than the current file. Thus if you try to do a :e and get a diagnostic that you haven't written the file, you can give a :w command and then a :e # command to redo the previous :e.

      You can write part of the buffer to a file by finding out the lines that bound the range to be written using ^G, and giving these numbers after the : and before the w, separated by ,'s. You can also mark these lines with m and then use an address of the form 'x,'y on the w command here.

      You can read another file into the buffer after the current line by using the :r command. You can similarly read in the output from a command, just use !cmd instead of a file name.

      If you wish to edit a set of files in succession, you can give all the names on the command line, and then edit each one in turn using the command :n. It is also possible to respecify the list of files to be edited by giving the :n command a list of file names, or a pattern to be expanded as you would have given it on the initial vi command.

      If you are editing large programs, you will find the :ta command very useful. It utilizes a data base of function names and their locations, which can be created by programs such as ctags, to quickly find a function whose name you give. If the :ta command will require the editor to switch files, then you must :w or abandon any changes before switching. You can repeat the :ta command without any arguments to look for the same tag again.

8.4.  More about searching for strings

      When you are searching for strings in the file with / and ?, the editor normally places you at the next or previous occurrence of the string. If you are using an operator such as d, c or y, then you may well wish to affect lines up to the line before the line containing the pattern. You can give a search of the form /pat/-n to refer to the n'th line before the next line containing pat, or you can use + instead of - to refer to the lines after the one containing pat. If you don't give a line offset, then the editor will affect characters up to the match place, rather than whole lines; thus use ``+0'' to affect to the line which matches.

      You can have the editor ignore the case of words in the searches it does by giving the command :se icCR. The command :se noicCR turns this off.

      Strings given to searches may actually be regular expressions. If you do not want or need this facility, you should

set nomagic
in your EXINIT. In this case, only the characters \(ua and $ are special in patterns. The character \ is also then special (as it is most everywhere in the system), and may be used to get at the an extended pattern matching facility. It is also necessary to use a \ before a / in a forward scan or a ? in a backward scan, in any case. The following table gives the extended forms when magic is set.
        at beginning of pattern, matches beginning of line
$       at end of pattern, matches end of line
.       matches any character
\<      matches the beginning of a word
\>      matches the end of a word
[str]   matches any single character in str
[str]   matches any single character not in str
[x-y]   matches any character between x and y
*       matches any number of the preceding pattern
If you use nomagic mode, then the . [ and * primitives are given with a preceding \.

8.5.  More about input mode

      There are a number of characters which you can use to make corrections during input mode. These are summarized in the following table.

^H      deletes the last input character
^W      deletes the last input word, defined as by b
erase   your erase character, same as ^H
kill    your kill character, deletes the input on this line
\       escapes a following ^H and your erase and kill
ESC     ends an insertion
DEL     interrupts an insertion, terminating it abnormally
CR      starts a new line
^D      backtabs over autoindent
0^D     kills all the autoindent
^D      same as 0^D, but restores indent next line
^V      quotes the next non-printing character into the file

      The most usual way of making corrections to input is by typing ^H to correct a single character, or by typing one or more ^W's to back over incorrect words. If you use # as your erase character in the normal system, it will work like ^H.

      Your system kill character, normally @, ^X or ^U, will erase all the input you have given on the current line. In general, you can neither erase input back around a line boundary nor can you erase characters which you did not insert with this insertion command. To make corrections on the previous line after a new line has been started you can hit ESC to end the insertion, move over and make the correction, and then return to where you were to continue. The command A which appends at the end of the current line is often useful for continuing.

      If you wish to type in your erase or kill character (say # or @) then you must precede it with a \, just as you would do at the normal system command level. A more general way of typing non-printing characters into the file is to precede them with a ^V. The ^V echoes as a \(ua character on which the cursor rests. This indicates that the editor expects you to type a control character. In fact you may type any character and it will be inserted into the file at that point.*

      If you are using autoindent you can backtab over the indent which it supplies by typing a ^D. This backs up to a shiftwidth boundary. This only works immediately after the supplied autoindent.

      When you are using autoindent you may wish to place a label at the left margin of a line. The way to do this easily is to type \(ua and then ^D. The editor will move the cursor to the left margin for one line, and restore the previous indent on the next. You can also type a 0 followed immediately by a ^D if you wish to kill all the indent and not have it come back on the next line.

8.6.  Upper case only terminals

      If your terminal has only upper case, you can still use vi by using the normal system convention for typing on such a terminal. Characters which you normally type are converted to lower case, and you can type upper case letters by preceding them with a \. The characters { ~ } | ` are not available on such terminals, but you can escape them as \( \\(ua \) \! \'. These characters are represented on the display in the same way they are typed.***

8.7.  Vi and ex

      Vi is actually one mode of editing within the editor ex. When you are running vi you can escape to the line oriented editor of ex by giving the command Q. All of the : commands which were introduced above are available in ex. Likewise, most ex commands can be invoked from vi using :. Just give them without the : and follow them with a CR.

      In rare instances, an internal error may occur in vi. In this case you will get a diagnostic and be left in the command mode of ex. You can then save your work and quit if you wish by giving a command x after the : which ex prompts you with, or you can reenter vi by giving ex a vi command.

      There are a number of things which you can do more easily in ex than in vi. Systematic changes in line oriented material are particularly easy. You can read the advanced editing documents for the editor ed to find out a lot more about this style of editing. Experienced users often mix their use of ex command mode and vi command mode to speed the work they are doing.

8.8.  Open mode: vi on hardcopy terminals and ``glass tty's'' ***

      If you are on a hardcopy terminal or a terminal which does not have a cursor which can move off the bottom line, you can still use the command set of vi, but in a different mode. When you give a vi command, the editor will tell you that it is using open mode. This name comes from the open command in ex, which is used to get into the same mode.

      The only difference between visual mode and open mode is the way in which the text is displayed.

      In open mode the editor uses a single line window into the file, and moving backward and forward in the file causes new lines to be displayed, always below the current line. Two commands of vi work differently in open: z and ^R. The z command does not take parameters, but rather draws a window of context around the current line and then returns you to the current line.

      If you are on a hardcopy terminal, the ^R command will retype the current line. On such terminals, the editor normally uses two lines to represent the current line. The first line is a copy of the line as you started to edit it, and you work on the line below this line. When you delete characters, the editor types a number of \'s to show you the characters which are deleted. The editor also reprints the current line soon after such changes so that you can see what the line looks like again.

      It is sometimes useful to use this mode on very slow terminals which can support vi in the full screen mode. You can do this by entering ex and using an open command.


      Bruce Englar encouraged the early development of this display editor. Peter Kessler helped bring sanity to version 2's command layout. Bill Joy wrote versions 1 and 2.0 through 2.7, and created the framework that users see in the present editor. Mark Horton added macros and other features and made the editor work on a large number of terminals and Unix systems.

Appendix: character functions

      This appendix gives the uses the editor makes of each character. The characters are presented in their order in the ASCII character set: Control characters come first, then most special characters, then the digits, upper and then lower case characters.

      For each character we tell a meaning it has as a command and any meaning it has during an insert. If it has only meaning as a command, then only this is discussed. Section numbers in parentheses indicate where the character is discussed; a `f' after the section number means that the character is mentioned in a footnote.

Not a command character. If typed as the first character of an insertion it is replaced with the last text inserted, and the insert terminates. Only 128 characters are saved from the last insert; if more characters were inserted the mechanism is not available. A ^@ cannot be part of the file due to the editor implementation (7.5f).
Backward window. A count specifies repetition. Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
As a command, scrolls down a half-window of text. A count gives the number of (logical) lines to scroll, and is remembered for future ^D and ^U commands (2.1, 7.2). During an insert, backtabs over autoindent white space at the beginning of a line (6.6, 7.5); this white space cannot be backspaced over.
Exposes one more line below the current screen in the file, leaving the cursor where it is if possible. (Version 3 only.)
Forward window. A count specifies repetition. Two lines of continuity are kept if possible (2.1, 6.1, 7.2).
Equivalent to :fCR, printing the current file, whether it has been modified, the current line number and the number of lines in the file, and the percentage of the way through the file that you are.
^H (BS)
Same as left arrow. (See h). During an insert, eliminates the last input character, backing over it but not erasing it; it remains so you can see what you typed if you wish to type something only slightly different (3.1, 7.5).
^I (TAB)
Not a command character. When inserted it prints as some number of spaces. When the cursor is at a tab character it rests at the last of the spaces which represent the tab. The spacing of tabstops is controlled by the tabstop option (4.1, 6.6).
^J (LF)
Same as down arrow (see j).
The ASCII formfeed character, this causes the screen to be cleared and redrawn. This is useful after a transmission error, if characters typed by a program other than the editor scramble the screen, or after output is stopped by an interrupt (5.4, 7.2f).
^M (CR)
A carriage return advances to the next line, at the first non-white position in the line. Given a count, it advances that many lines (2.3). During an insert, a CR causes the insert to continue onto another line (3.1).
Same as down arrow (see j).
Same as up arrow (see k).
Not a command character. In input mode, ^Q quotes the next character, the same as ^V, except that some teletype drivers will eat the ^Q so that the editor never sees it.
Redraws the current screen, eliminating logical lines not corresponding to physical lines (lines with only a single @ character on them). On hardcopy terminals in open mode, retypes the current line (5.4, 7.2, 7.8).
Unused. Some teletype drivers use ^S to suspend output until ^Qis
Not a command character. During an insert, with autoindent set and at the beginning of the line, inserts shiftwidth white space.
Scrolls the screen up, inverting ^D which scrolls down. Counts work as they do for ^D, and the previous scroll amount is common to both. On a dumb terminal, ^U will often necessitate clearing and redrawing the screen further back in the file (2.1, 7.2).
Not a command character. In input mode, quotes the next character so that it is possible to insert non-printing and special characters into the file (4.2, 7.5).
Not a command character. During an insert, backs up as b would in command mode; the deleted characters remain on the display (see ^H) (7.5).
Exposes one more line above the current screen, leaving the cursor where it is if possible. (No mnemonic value for this key; however, it is next to ^U which scrolls up a bunch.) (Version 3 only.)
If supported by the Unix system, stops the editor, exiting to the top level shell. Same as :stopCR. Otherwise, unused.
^[ (ESC)
Cancels a partially formed command, such as a z when no following character has yet been given; terminates inputs on the last line (read by commands such as : / and ?); ends insertions of new text into the buffer. If an ESC is given when quiescent in command state, the editor rings the bell or flashes the screen. You can thus hit ESC if you don't know what is happening till the editor rings the bell. If you don't know if you are in insert mode you can type ESCa, and then material to be input; the material will be inserted correctly whether or not you were in insert mode when you started (1.5, 3.1, 7.5).
Searches for the word which is after the cursor as a tag. Equivalent to typing :ta, this word, and then a CR. Mnemonically, this command is ``go right to'' (7.3).
Equivalent to :e #CR, returning to the previous position in the last edited file, or editing a file which you specified if you got a `No write since last change diagnostic' and do not want to have to type the file name again (7.3). (You have to do a :w before ^\(ua will work in this case. If you do not wish to write the file you should do :e! #CR instead.)
Unused. Reserved as the command character for the Tektronix 4025 and 4027 terminal.
Same as right arrow (see l).
An operator, which processes lines from the buffer with reformatting commands. Follow ! with the object to be processed, and then the command name terminated by CR. Doubling ! and preceding it by a count causes count lines to be filtered; otherwise the count is passed on to the object after the !. Thus 2!}fmtCR reformats the next two paragraphs by running them through the program fmt. If you are working on LISP, the command !%grindCR,* given at the beginning of a function, will run the text of the function through the LISP grinder (6.7, 7.3). To read a file or the output of a command into the buffer use :r (7.3). To simply execute a command use :! (7.3).

Precedes a named buffer specification. There are named buffers 1-9 used for saving deleted text and named buffers a-z into which you can place text (4.3, 6.3)
The macro character which, when followed by a number, will substitute for a function key on terminals without function keys (6.9). In input mode, if this is your erase character, it will delete the last character you typed in input mode, and must be preceded with a \ to insert it, since it normally backs over the last input character you gave.
Moves to the end of the current line. If you :se listCR, then the end of each line will be shown by printing a $ after the end of the displayed text in the line. Given a count, advances to the count'th following end of line; thus 2$ advances to the end of the following line.
Moves to the parenthesis or brace { } which balances the parenthesis or brace at the current cursor position.
A synonym for :&CR, by analogy with the ex & command.
When followed by a ' returns to the previous context at the beginning of a line. The previous context is set whenever the current line is moved in a non-relative way. When followed by a letter a-z, returns to the line which was marked with this letter with a m command, at the first non-white character in the line. (2.2, 5.3). When used with an operator such as d, the operation takes place over complete lines; if you use `, the operation takes place from the exact marked place to the current cursor position within the line.
Retreats to the beginning of a sentence, or to the beginning of a LISP s-expression if the lisp option is set. A sentence ends at a . ! or ? which is followed by either the end of a line or by two spaces. Any number of closing ) ] " and ' characters may appear after the . ! or ?, and before the spaces or end of line. Sentences also begin at paragraph and section boundaries (see { and [[ below). A count advances that many sentences (4.2, 6.8).
Advances to the beginning of a sentence. A count repeats the effect. See ( above for the definition of a sentence (4.2, 6.8).
Same as CR when used as a command.
Reverse of the last f F t or T command, looking the other way in the current line. Especially useful after hitting too many ; characters. A count repeats the search.
Retreats to the previous line at the first non-white character. This is the inverse of + and RETURN. If the line moved to is not on the screen, the screen is scrolled, or cleared and redrawn if this is not possible. If a large amount of scrolling would be required the screen is also cleared and redrawn, with the current line at the center (2.3).
Repeats the last command which changed the buffer. Especially useful when deleting words or lines; you can delete some words/lines and then hit . to delete more and more words/lines. Given a count, it passes it on to the command being repeated. Thus after a 2dw, 3. deletes three words (3.3, 6.3, 7.2, 7.4).
Reads a string from the last line on the screen, and scans forward for the next occurrence of this string. The normal input editing sequences may be used during the input on the bottom line; an returns to command state without ever searching. The search begins when you hit CR to terminate the pattern; the cursor moves to the beginning of the last line to indicate that the search is in progress; the search may then be terminated with a DEL or RUB, or by backspacing when at the beginning of the bottom line, returning the cursor to its initial position. Searches normally wrap end-around to find a string anywhere in the buffer.

When used with an operator the enclosed region is normally affected. By mentioning an offset from the line matched by the pattern you can force whole lines to be affected. To do this give a pattern with a closing a closing / and then an offset +n or -n.

To include the character / in the search string, you must escape it with a preceding \. A \(ua at the beginning of the pattern forces the match to occur at the beginning of a line only; this speeds the search. A $ at the end of the pattern forces the match to occur at the end of a line only. More extended pattern matching is available, see section 7.4; unless you set nomagic in your .exrc file you will have to preceed the characters . [ * and ~ in the search pattern with a \ to get them to work as you would naively expect (1.5, 2,2, 6.1, 7.2, 7.4).

Moves to the first character on the current line. Also used, in forming numbers, after an initial 1-9.
Used to form numeric arguments to commands (2.3, 7.2).
A prefix to a set of commands for file and option manipulation and escapes to the system. Input is given on the bottom line and terminated with an CR, and the command then executed. You can return to where you were by hitting DEL or RUB if you hit : accidentally (see primarily 6.2 and 7.3).
Repeats the last single character find which used f F t or T. A count iterates the basic scan (4.1).
An operator which shifts lines left one shiftwidth, normally 8 spaces. Like all operators, affects lines when repeated, as in <<. Counts are passed through to the basic object, thus 3<< shifts three lines (6.6, 7.2).
Reindents line for LISP, as though they were typed in with lisp and autoindent set (6.8).
An operator which shifts lines right one shiftwidth, normally 8 spaces. Affects lines when repeated as in >>. Counts repeat the basic object (6.6, 7.2).
Scans backwards, the opposite of /. See the / description above for details on scanning (2.2, 6.1, 7.4).
A macro character (6.9). If this is your kill character, you must escape it with a \ to type it in during input mode, as it normally backs over the input you have given on the current line (3.1, 3.4, 7.5).
Appends at the end of line, a synonym for $a (7.2).
Backs up a word, where words are composed of non-blank sequences, placing the cursor at the beginning of the word. A count repeats the effect (2.4).
Changes the rest of the text on the current line; a synonym for c$.
Deletes the rest of the text on the current line; a synonym for d$.
Moves forward to the end of a word, defined as blanks and non-blanks, like B and W. A count repeats the effect.
Finds a single following character, backwards in the current line. A count repeats this search that many times (4.1).
Goes to the line number given as preceding argument, or the end of the file if no preceding count is given. The screen is redrawn with the new current line in the center if necessary (7.2).
Home arrow. Homes the cursor to the top line on the screen. If a count is given, then the cursor is moved to the count'th line on the screen. In any case the cursor is moved to the first non-white character on the line. If used as the target of an operator, full lines are affected (2.3, 3.2).
Inserts at the beginning of a line; a synonym for \(uai.
Joins together lines, supplying appropriate white space: one space between words, two spaces after a ., and no spaces at all if the first character of the joined on line is ). A count causes that many lines to be joined rather than the default two (6.5, 7.1f).
Moves the cursor to the first non-white character of the last line on the screen. With a count, to the first non-white of the count'th line from the bottom. Operators affect whole lines when used with L (2.3).
Moves the cursor to the middle line on the screen, at the first non-white position on the line (2.3).
Scans for the next match of the last pattern given to / or ?, but in the reverse direction; this is the reverse of n.
Opens a new line above the current line and inputs text there up to an ESC. A count can be used on dumb terminals to specify a number of lines to be opened; this is generally obsolete, as the slowopen option works better (3.1).
Puts the last deleted text back before/above the cursor. The text goes back as whole lines above the cursor if it was deleted as whole lines. Otherwise the text is inserted between the characters before and at the cursor. May be preceded by a named buffer specification "x to retrieve the contents of the buffer; buffers 1-9 contain deleted material, buffers a-z are available for general use (6.3).
Quits from vi to ex command mode. In this mode, whole lines form commands, ending with a RETURN. You can give all the : commands; the editor supplies the : as a prompt (7.7).
Replaces characters on the screen with characters you type (overlay fashion). Terminates with an ESC.
Changes whole lines, a synonym for cc. A count substitutes for that many lines. The lines are saved in the numeric buffers, and erased on the screen before the substitution begins.
Takes a single following character, locates the character before the cursor in the current line, and places the cursor just after that character. A count repeats the effect. Most useful with operators such as d (4.1).
Restores the current line to its state before you started changing it (3.5).
Moves forward to the beginning of a word in the current line, where words are defined as sequences of blank/non-blank characters. A count repeats the effect (2.4).
Deletes the character before the cursor. A count repeats the effect, but only characters on the current line are deleted.
Yanks a copy of the current line into the unnamed buffer, to be put back by a later p or P; a very useful synonym for yy. A count yanks that many lines. May be preceded by a buffer name to put lines in that buffer (7.4).
Exits the editor. (Same as :xCR.) If any changes have been made, the buffer is written out to the current file. Then the editor quits.
Backs up to the previous section boundary. A section begins at each macro in the sections option, normally a `.NH' or `.SH' and also at lines which which start with a formfeed ^L. Lines beginning with { also stop [[; this makes it useful for looking backwards, a function at a time, in C programs. If the option lisp is set, stops at each ( at the beginning of a line, and is thus useful for moving backwards at the top level LISP objects. (4.2, 6.1, 6.6, 7.2).
Forward to a section boundary, see [[ for a definition (4.2, 6.1, 6.6, 7.2).
Moves to the first non-white position on the current line (4.4).
When followed by a ` returns to the previous context. The previous context is set whenever the current line is moved in a non-relative way. When followed by a letter a-z, returns to the position which was marked with this letter with a m command. When used with an operator such as d, the operation takes place from the exact marked place to the current position within the line; if you use ', the operation takes place over complete lines (2.2, 5.3).
Appends arbitrary text after the current cursor position; the insert can continue onto multiple lines by using RETURN within the insert. A count causes the inserted text to be replicated, but only if the inserted text is all on one line. The insertion terminates with an ESC (3.1, 7.2).
Backs up to the beginning of a word in the current line. A word is a sequence of alphanumerics, or a sequence of special characters. A count repeats the effect (2.4).
An operator which changes the following object, replacing it with the following input text up to an ESC. If more than part of a single line is affected, the text which is changed away is saved in the numeric named buffers. If only part of the current line is affected, then the last character to be changed away is marked with a $. A count causes that many objects to be affected, thus both 3c) and c3) change the following three sentences (7.4).
An operator which deletes the following object. If more than part of a line is affected, the text is saved in the numeric buffers. A count causes that many objects to be affected; thus 3dw is the same as d3w (3.3, 3.4, 4.1, 7.4).
Advances to the end of the next word, defined as for b and w. A count repeats the effect (2.4, 3.1).
Finds the first instance of the next character following the cursor on the current line. A count repeats the find (4.1).

Arrow keys h, j, k, l, and H.

Left arrow. Moves the cursor one character to the left. Like the other arrow keys, either h, the left arrow key, or one of the synonyms (^H) has the same effect. On v2 editors, arrow keys on certain kinds of terminals (those which send escape sequences, such as vt52, c100, or hp) cannot be used. A count repeats the effect (3.1, 7.5).
Inserts text before the cursor, otherwise like a (7.2).
Down arrow. Moves the cursor one line down in the same column. If the position does not exist, vi comes as close as possible to the same column. Synonyms include ^J (linefeed) and ^N.
Up arrow. Moves the cursor one line up. ^P is a synonym.
Right arrow. Moves the cursor one character to the right. SPACE is a synonym.
Marks the current position of the cursor in the mark register which is specified by the next character a-z. Return to this position or use with an operator using ` or ' (5.3).
Repeats the last / or ? scanning commands (2.2).
Opens new lines below the current line; otherwise like O (3.1).
Puts text after/below the cursor; otherwise like P (6.3).
Replaces the single character at the cursor with a single character you type. The new character may be a RETURN; this is the easiest way to split lines. A count replaces each of the following count characters with the single character given; see R above which is the more usually useful iteration of r (3.2).
Changes the single character under the cursor to the text which follows up to an ESC; given a count, that many characters from the current line are changed. The last character to be changed is marked with $ as in c (3.2).
Advances the cursor upto the character before the next character typed. Most useful with operators such as d and c to delete the characters up to a following character. You can use . to delete more if this doesn't delete enough the first time (4.1).
Undoes the last change made to the current buffer. If repeated, will alternate between these two states, thus is its own inverse. When used after an insert which inserted text on more than one line, the lines are saved in the numeric named buffers (3.5).
Advances to the beginning of the next word, as defined by b (2.4).
Deletes the single character under the cursor. With a count deletes deletes that many characters forward from the cursor position, but only on the current line (6.5).
An operator, yanks the following object into the unnamed temporary buffer. If preceded by a named buffer specification, "x, the text is placed in that buffer also. Text can be recovered by a later p or P (7.4).
Redraws the screen with the current line placed as specified by the following character: RETURN specifies the top of the screen, . the center of the screen, and - at the bottom of the screen. A count may be given after the z and before the following character to specify the new screen size for the redraw. A count before the z gives the number of the line to place in the center of the screen instead of the default current line. (5.4)
Retreats to the beginning of the beginning of the preceding paragraph. A paragraph begins at each macro in the paragraphs option, normally `.IP', `.LP', `.PP', `.QP' and `.bp'. A paragraph also begins after a completely empty line, and at each section boundary (see [[ above) (4.2, 6.8, 7.6).
Places the cursor on the character in the column specified by the count (7.1, 7.2).
Advances to the beginning of the next paragraph. See { for the definition of paragraph (4.2, 6.8, 7.6).
^? (DEL)
Interrupts the editor, returning it to command accepting state (1.5, 7.5) .