Section 7.4. Movement Commands

7.4. Movement Commands

Some versions of vi don't recognize extended keyboard keys (e.g., arrow keys, Page Up, Page Down, Home, Insert, and Delete); some do. All, however, recognize the keys in this section. Many users of vi prefer to use these keys, because it helps them keep their fingers on the home row of the keyboard. A number preceding a command repeats the movement. Movement commands are also objects for change, delete, and yank operations.

7.4.1. Character

Command

Action

h, j, k, l

Left, down, up, right ( , , , ,)

Spacebar

Right

Backspace

Left

Ctrl-H

Left


7.4.2. Text

Command

Action

w, b

Forward, backward by word ( treating punctuation marks as words).

W, B

Forward, backward by word (recognizing only whitespace, not punctuation, as separators).

e

End of word (treating a punctuation mark as the end of a word).

E

End of word (recognizing only whitespace as the end of a word).

ge

End of previous word (treating a punctuation mark as the end of a word). ( vim )

gE

End of previous word (recognizing only whitespace as the end of a word). ( vim )

), (

Beginning of next , current sentence .

}, {

Beginning of next, current paragraph.

]], [[

Beginning of next, current section.

][, [ ]

End of next, current section. ( vim )


7.4.3. Lines

Long lines in a file may show up on the screen as multiple lines. While most commands work on the lines as defined in the file, a few commands work on lines as they appear on the screen.

Command

Action

0, $

First, last position of current line.

^, _

First nonblank character of current line.

+, -

First character of next, previous line.

Return

First nonblank character of next line.

n

Column n of current line.

g0, g$

First, last position of screen line. ( vim )

g^

First nonblank character of screen line. ( vim )

gm

Middle of screen line. ( vim )

gk, gj

Move up, down one screen line. ( vim )

H

Top line of screen.

M

Middle line of screen.

L

Last line of screen.

n H

n lines after top line of screen.

n L

n lines before last line of screen.


7.4.4. Screens

Command

Action

Ctrl-F, Ctrl-B

Scroll forward, backward one screen.

Ctrl-D, Ctrl-U

Scroll down, up one-half screen.

Ctrl-E, Ctrl-Y

Show one more line at bottom, top of window.

z Return

Reposition line with cursor to top of screen.

z.

Reposition line with cursor to middle of screen.

z-

Reposition line with cursor to bottom of screen.

Ctrl-L

Redraw screen (without scrolling).


7.4.5. Searches

Command

Action

/ pattern

Search forward for pattern .

/

Repeat previous search forward.

/ pattern /+ n

Go to line n after pattern .

? pattern

Search backward for pattern .

?

Repeat previous search backward.

? pattern ?- n

Go to line n before pattern .

n

Repeat previous search.

N

Repeat previous search in opposite direction.

%

Find match of current parenthesis, brace , or bracket .

*

Search forward for word under cursor. Matches only exact words. ( vim )

#

Search backward for word under cursor. Matches only exact words. ( vim )

g*

Search backward for word under cursor. Matches the characters of this word when embedded in a longer word. ( vim )

g#

Search backward for word under cursor. Matches the characters of this word when embedded in a longer word. ( vim )

f x

Move forward to x on current line.

F x

Move backward to x on current line.

t x

Move forward to just before x in current line.

T x

Move backward to just after x in current line.

,

Reverse search direction of last f, F, t, or T.

;

Repeat last character search (f, F, t, or T).

:noh

Suspend search highlighting until next search. ( vim ).


7.4.5.1. Line numbering

Command

Action

Ctrl-G

Display current filename and line number.

gg

Move to first line in file. ( vim )

n G

Move to line number n .

G

Move to last line in file.

: n

Move to line number n .


7.4.5.2. Marking position

Command

Action

m x

Mark current position with character x .

' x

(backquote) Move cursor to mark x .

' x

(apostrophe) Move to start of line containing x .

''

(backquotes) Return to previous mark (or location prior to search).

''

( apostrophes ) Like preceding, but return to start of line.

'"

(apostrophe quote) Move to position when last editing the file. ( vim )

'[,']

(backquote bracket) Move to beginning/end of previous text operation. ( vim )

'[,']

(apostrophe bracket) Like preceding, but return to start of line where operation occurred. ( vim )

''.

(backquote period) Move to last change in file. ( vim )

'.

(apostrophe period) Like the previous item, but return to start of line. ( vim )

:marks

List active marks. ( vim )




MAC OS X Tiger in a Nutshell
Mac OS X Tiger in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009437
EAN: 2147483647
Year: 2003
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net