Perform different editing actions using single keystrokes. Highlight or select text for copying, deleting, and so on.Ĭommand mode is the default mode of Vim, but you can switch from command mode to any other mode by using a single keystroke. Some of the keys to switch modes are listed here. Switches to insert mode and inserts text to the left of the cursor. Switches to insert mode and adds text at the end of a line. Switches to insert mode and inserts text at the beginning of a line. Switches to insert mode and inserts text on a new line below the cursor. Switches to insert mode and inserts text on a new line above the cursor. Switches to visual mode to enable selection, one character at a time. V Switches to visual mode to enable selection, one line at a time. Switches to execute mode to enable users to enter commands. In command mode, when you enter the colon (:) operator, a small command prompt section appears at the bottom-left of the editor. This indicates that you are in execute mode and can run commands supported by Vim. Some commands supported by Vim are listed in the following table. Saves a file with a file name if it is being saved for the first time. Quits when no changes have been made after the last save. Reverts to the last saved format without closing the file.Įxecutes the command and displays the result in the Vim interface. Motions are single-key shortcuts that are used to navigate through files in command mode. These keys position the cursor anywhere within a document. They can be used for moving the cursor through characters, words, lines, or even huge blocks of text. Move to the beginning of the current line. Move to the end of the current word or to the end of the next word if you are already at the end of the word. Move the cursor to the bottom of the screen. Move the cursor to the first line of the screen. Move the cursor to the specified line number. Move the cursor to the first line of the file. Move the cursor to the last line of the file. In addition to using the h, j, k, and l keys to navigate through the editor, you can also use the Up, Down, Left, and Right Arrow keys. The conventional navigation keys such as Home, End, Page Up, and Page Down also work in Vim. Editing OperatorsĮditing operators in command mode are powerful tools that can be used to manipulate text with simple keystrokes. They can also be used in combination with motions to edit multiple characters. Some of the frequently used editing operators are listed here. Editing Operatorĭelete the character selected by the cursor. Paste text on the line directly below the cursor. Paste text on the line directly above the cursor. Search through the document for specific text. Search backward through the document for specific text. Write the file only if changes were made, then quit the Vim editor.Ī count is a number that multiplies the effect of keystrokes in Vim. It can be used in combination with motions, operators, or both. When used with a motion, cursor movement is multiplied according to the count specified.
How to find out which files were installed with a.
i - change to insert mode (before cursor).move the cursor with arrow keys if there aren't any arrow keys, use j,k,h,l.For example, entering 99 followed by the down arrow will move the cursor down 99 lines. You can precede most commands with a number indicating how many times to perform a command. Command mode is used to navigate, search, and issue other commands. Vi has two modes, command and insert (really, three if you count replace mode). I've added and changed things from the original text. Note: a chunk of this small guide came from a web page I found long ago, but I don't remember where so I can't give proper credit. If you gave vi a whirl and don't see the beauty of it, give the nano editor a try. Vim It is the default editor when changing a crontab.
On Mac OS X (and Linux), vi is symlinked to vim (vi improved), a more modern free software version. There may be times when vi is the only text editor available, so it helps to at least know the basics. While obtuse, vi is extremely powerful and efficient. Vi is an one of two powerhouse text editors in the Unix world, the other being EMACS.