You are previewing vi and Vim Editors Pocket Reference, 2nd Edition.

vi and Vim Editors Pocket Reference, 2nd Edition

Cover of vi and Vim Editors Pocket Reference, 2nd Edition by Arnold Robbins Published by O'Reilly Media, Inc.
  1. vi and Vim Editors Pocket Reference
  2. 1. vi and Vim Editors Pocket Reference
    1. Introduction
    2. Conventions
    3. Acknowledgments
    4. Command-Line Options
    5. vi Commands
      1. Movement Commands
      2. Editing Commands
      3. Exit Commands
      4. Solaris vi Command-Mode Tag Commands
      5. Buffer Names
      6. Buffer and Marking Commands
    6. Input Mode Shortcuts
      1. Word Abbreviation
      2. Command and Input Mode Maps
      3. Executable Buffers
      4. Automatic Indentation
    7. Substitution and Regular Expressions
      1. The Substitute Command
      2. vi Regular Expressions
      3. POSIX Bracket Expressions
      4. Metacharacters Used in Replacement Strings
      5. More Substitution Tricks
    8. ex Commands
      1. Command Syntax
      2. Address Symbols
      3. Command Option Symbols
      4. Alphabetical List of Commands
    9. Initialization
    10. Recovery
    11. vi set Options
    12. Nothing like the Original
    13. Enhanced Tags and Tag Stacks
      1. Exuberant ctags
      2. Solaris vi Tag Stacking
    14. Vim—vi Improved
      1. Important Command-Line Options
      2. Vim Window Management
      3. Tabbed Editing
      4. Vim Extended Regular Expressions
      5. Command-Line History and Completion
      6. Tag Stacks
      7. Edit-Compile Speedup
      8. Programming Assistance
      9. Folding and Unfolding Text
      10. Insertion Completion Facilities
      11. Diff Mode
      12. Vim Scripting
      13. Vim set Options
    15. nvi—New vi
      1. Important Command-Line Options
      2. nvi Window Management Commands
      3. nvi Extended Regular Expressions
      4. Command-Line History and Completion Options
      5. Tag Stacks
      6. nvi 1.79 set Options
    16. elvis
      1. Important Command-Line Options
      2. elvis Window Management
      3. elvis Extended Regular Expressions
      4. Command-Line History and Completion Movement Keys
      5. Tag Stacks
      6. Edit-Compile Speedup
      7. elvis 2.2 set Options
    17. vile—vi like Emacs
      1. Important Command-Line Options
      2. vile Window Management Commands
      3. vile Extended Regular Expressions
      4. Command-Line History and Completion
      5. Tag Stacks
      6. Edit-Compile Speedup
      7. vile 9.8 set Options
    18. Internet Resources for vi
    19. Program Source and Contact Information
  3. Index
  4. About the Author
  5. Copyright
O'Reilly logo

vi Commands

vi commands are used in “screen” mode (the default), where you use the commands to move around the screen and to perform operations on the text.

Most vi commands follow a general pattern:

[command][number]textobject

or the equivalent form:

[number][command]textobject

Movement Commands

vi movement commands distinguish between two kinds of “words.” The lowercase commands define a word as a contiguous sequence of underscores, letters, and digits. The uppercase commands define a word as a contiguous sequence of nonwhitespace characters.

CommandMeaning
Character 
h, j, k, l

Left, down, up, right (, ↓, ↑, )

Text 
w, W, b, B

Forward, backward by word

e, E

End of word

), (

Beginning of next, previous sentence

}, {

Beginning of next, previous paragraph

]], [[

Beginning of next, previous section

Lines 
ENTER

First nonblank character of next line

0, $

First, last position of current line

^

First nonblank character of current line

+, -

First nonblank character of next, previous line

n |

Column n of current line

H, M, L

Top, middle, last line of screen

n H

n (number) of lines after top line

n L

n (number) of lines before last line

Scrolling 
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 ENTER

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)

CommandMeaning
Searches 
/pattern

Search forward ...

The best content for your career. Discover unlimited learning on demand for around $1/day.