In addition to the keys listed here, your keyboard's "arrow" keys will be interpreted as the appropriate cursor movement commands. The same goes for (PgUp) and (PgDn), if your keyboard has them. The (Insert) key will toggle between insert mode and replace mode. There is a colon mode command (":map", to be described later) which will allow you to define other keys, such as function keys.
A tip: visual command mode looks a lot like text input mode. If you forget which mode you're in, just hit the (Esc) key. If Elvis beeps, then you're in visual command mode. If Elvis does not beep, then you were in input mode, but by hitting (Esc) you will have switched to visual command mode. So, one way or another, after (Esc) Elvis will be ready for a command.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | P | Paste text before the cursor | | p | Paste text after the cursor | | count J | Join lines, to form one big line | | count X | Delete the character(s) to the left of the cursor | | count x | Delete the character that the cursor's on | | count ~ | Switch a character between uppercase & lowercase | | count r key | Replace "count" chars by a given character | | R inp | Overtype | | count a inp | Insert text after the cursor | | count A inp | Append at end of the line | | count i inp | Insert text at the cursor | | count I inp | Insert at the front of the line (after indents) | | count o inp | Open a new line below the current line | | count O inp | Open up a new line above the current line | | count . | Repeat the previous "edit" command | | count u | Undo the previous edit command | | count ^R | Redo commands which were undone by the u command | | U | Undo all recent changes to the current line | ^--------------^------------------------------------------------------^
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | < mv | Shift text left | | > mv | Shift text right | | ! mv text| Run selected lines thru an external filter program | | = mv | Reformat | | c mv inp | Change text | | d mv | Delete text | | y mv | Yank text (copy it into a cut buffer) | ^--------------^------------------------------------------------------^These commands all affect text between the cursor's current position and some other position. There are three ways that you can specify that other position:
When applied to characters selected via the v command, the = command uses elvis' built-in calculator to evaluate the characters, and then replaces the original text with the result of that evaluation. For example, if you move the cursor to the start of a parenthesized arithmetic expression and hit v%= then the expression will be simplified.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | C inp | Change text from the cursor to the end of the line | | D | Delete text from the cursor to the end of the line | | count S inp | Change lines, like "count" cc | | count s inp | Replace characters, like "count" cl | | count Y | Yank text line(s) (copy them into a cut buffer) | ^--------------^------------------------------------------------------^
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | 0 | If not part of count, move to 1st char of this line | | ^ | Move to the front of the current line (after indent) | | $ | Move to the rear of the current line | | count | | Move to column "count" (defaulting to column 1) | | count ^X | Move to column "count" (defaulting to the right edge)| | count ^M | Move to the front of the next line | | count + | Move to the front of the next line | | count - | Move to the front of the preceding line | | count G | Move to line #"count" (default is the bottom line) | | count h | Move left | | count ^H | Move left | | count l | Move right | | count Space | Move right | | count j | Move down | | count ^J | Move down | | count ^N | Move down | | count k | Move up | | count ^P | Move up | | count _ | Move to the current line | ^--------------^------------------------------------------------------^
For the purposes of this command, the "line number" of the cursor position is defined to be one plus the number of newline characters which precede it in the buffer. This definition is used regardless of what display mode you happen to be using. The number and ruler options use the same definition.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | count H | Move to home row (the line at the top of the screen) | | M | Move to middle row | | count L | Move to last row (i.e., line at bottom of window) | ^--------------^------------------------------------------------------^
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | / text | Search forward for a given regular expression | | ? text | Search backward for a given regular expression | | ^A | Search for next occurrence of word at cursor | | n | Repeat the previous search | | N | Repeat previous search, but in the opposite direction| ^--------------^------------------------------------------------------^All of these search commands are affected by the magic, ignorecase, wrapscan, and autoselect options.
When entering the regular expression, you can append a closing delimiter (/ or ?, as appropriate) followed by a line delta (+ or - followed by a line number) to move the cursor to the start of a line after or before the matching text. You can also use v or n flags to temporarily force the autoselect option on or off for that one search.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | count % | Move to matching (){}[] or to a given % of file | | count F key | Move leftward to a given character | | count f key | Move rightward to a given character | | count T key | Move leftward *almost* to a given character | | count t key | Move rightward *almost* to a given character | | count , | Repeat the previous [fFtT] but in the other direction| | count ; | Repeat the previous [fFtT] cmd | ^--------------^------------------------------------------------------^
However, if a count is supplied, then it is used as a percentage from 1 to 100, and the cursor is moved to that percentage of the way into the buffer. For example, typing 50% will move the cursor to the middle of the buffer.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | count w | Move forward "count" words | | count e | Move forward to the end of the current word | | count b | Move back "count" words | | count W | Move forward "count" Words | | count E | Move end of Word | | count B | Move back Word | ^--------------^------------------------------------------------------^The uppercase and lowercase versions of these commands differ only in their definition of a "word." The uppercase commands consider a word to be any sequence of non-whitespace characters, bound by whitespace characters or the ends of the buffer.
The lowercase commands define a word as either a sequence of alphanumeric characters, or a sequence of punctuation characters, but not a mixture of the two; these words can be bound by whitespace, the ends of the buffer, or by characters from the other class of lowercase word. (I.e, an alphanumeric word can be bound by punctuation characters, and a punctuation word can be bound by alphanumeric characters.) The underscore character is considered to be alphanumeric.
NOTE: These commands are often used as the targets of the operator commands, as in dw or de. When used this way, the difference between them is that dw includes any whitespace after the word, but de does not.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | count ( | Move backward "count" sentences | | count ) | Move forward "count" sentences | | count { | Move back "count" paragraphs | | count } | Move forward "count" paragraphs | | [ [ | Move back 1 section | | ] ] | Move forward 1 section | ^--------------^------------------------------------------------------^
The exact definition of the end of a sentence depends on the values of the sentenceend, sentencegap, and sentencequote options. The default values of those options define a sentence end to be a period, question mark, or exclamation mark, followed by either a newline character, or two or more space characters. Any number of double-quote characters or closing parentheses may appear between the punctuation and the whitespace.
Note: There are also [key and ]key commands for recording keystrokes. Those commands are not related to the [[ and ]] movement commands.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | m key | Mark a line or character | | ' key | Move to a marked line | | ` key | Move to a marked character | | V | Start marking lines for c d y < > or ! | | v | Start marking characters for c d y < > or ! | | ^V | Start marking a rectangle for c d y < > or ! | ^--------------^------------------------------------------------------^
The distinction between character-movement and line-movement becomes more significant when you're using the movement command as the target of an operator command. For example, after an ma command and some cursor movement, the command d'a would delete whole lines, but the command d`a would delete only the text between the cursor and the "a" mark.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | ^F | Move toward the bottom of the file by 1 screen full | | ^B | Move toward the top of the file by 1 screen full | | z key | Scroll current line to window's +top -bottom .middle | | count ^D | Scroll forward "count" lines (default 1/2 screen) | | count ^E | Scroll forward "count" lines (default 1 line) | | count ^U | Scroll backward "count" lines (default 1/2 screen) | | count ^Y | Scroll backward "count" lines (default 1 line) | ^--------------^------------------------------------------------------^
98z+
will move the cursor to line 98 and then scroll as necessary
to bring 98 to the top of the window.
Elvis also supports zH, zM, and zL as synonyms for those commands. These may be easier to remember, because they are somewhat analogous to the H, M, and L commands. In addition, zz is an easy-to-type synonym for scrolling a line to middle of the window.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | ^W s | Split current window | | ^W ] | Split window, then look up tag at cursor | | ^W n | Split window, and create a new buffer | | ^W q | Save buffer & close window, like ZZ | | ^W c | Hide buffer & close window | | ^W d | Toggle the display mode | | ^W S | Toggle the sidescroll option | | ^W j | Move down to next window | | ^W k | Move up to previous window | | count ^W ^W | Move to next window, or to the "count" window | ^--------------^------------------------------------------------------^
bufdisplay
is set to a syntax-coloring mode or "hex" then
it toggles between that mode and "normal".
If bufdisplay
is "normal", then this command toggles between
that mode and the "hex" mode.
NOTE: In addition to the commands shown here, some user interfaces may support extensions to these commands. For example, the termcap interface uses ^W+ to increase the size of the current window, ^W- to reduce the size of the current window, and ^W\ to make the current window as large as possible.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | " key | Select which cut buffer to use next | | @ key | Execute the contents of a cut-buffer as VI commands | | [ key | Start recording keystrokes into a cut-buffer | | ] key | Stop recording keystrokes into a cut-buffer | | : text | Run single EX cmd | | Q | Quit to EX mode | | K | Run keywordprg on the word at the cursor | | Z Z | Save the file & exit | | ^Z | Either suspend elvis, or fork a shell | | ^G | Show file status, and the current line # | | ^L | Redraw the screen | | * | Go to the next error in the errlist | | ^I | In HTML mode, move forward to next link | | ^T | Return to source of previous :tag or ^] command. | | ^] | If the cursor is on a tag name, go to that tag | | ^^ | Switch to the previous file, like ":e #" | | count # key | Increment a number | | count & | Repeat the previous ":s//" command here | ^--------------^------------------------------------------------------^
Note: There are also [[ and ]] commands for moving the cursor to the start of a section. Those movement commands are unrelated to these [key and ]key keystroke recording commands.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | NUL | (undefined) | | ^A | Search for next occurrence of word at cursor | | ^B | Move toward the top of the file by 1 screen full | | ^C | (undefined; may abort a time-consuming command) | | count ^D | Scroll forward "count" lines (default 1/2 screen) | | count ^E | Scroll forward "count" lines (default 1 line) | | ^F | Move toward the bottom of the file by 1 screen full | | ^G | Show file status, and the current line # | | count ^H | Move left | | ^I | (Tab) In "html" display mode, move to next hyperlink | | count ^J | Move down | | ^K | (undefined) | | ^L | Redraw the screen | | count ^M | Move to the front of the next line | | count ^N | Move down | | ^O | ignored, to simplify implementation of "visual" map | | count ^P | Move up | | ^Q | (undefined; may resume stopped output) | | count ^R | Redo commands which were undone by the u command | | ^S | (undefined; may stop output) | | ^T | Return to source of previous :tag or ^] command. | | count ^U | Scroll backward "count" lines (default 1/2 screen) | | ^V | Start marking a rectangle for c d y < > or ! | | count ^W ^W | Move to next window, or to the "count" window | | ^W S | Toggle the sidescroll option | | ^W ] | Split window, then look up tag at cursor | | ^W c | Hide buffer & close window | | ^W d | Toggle the display mode | | ^W j | Move down to next window | | ^W k | Move up to previous window | | ^W n | Split window, and create a new buffer | | ^W q | Save buffer & close window, like ZZ | | ^W s | Split current window | | count ^X | Move to column "count" (defaulting to the right edge)| | count ^Y | Scroll backward "count" lines (default 1 line) | | ^Z | Either suspend elvis, or fork a shell | | ^[ | (Escape) Cancels a partially-entered command | | ^\ | (undefined; may cause core dump) | | ^] | If the cursor is on a tag name, go to that tag | | ^^ | Switch to the previous file, like ":e #" | | ^_ | (undefined) | | count Space | Move right | | ! mv | Run selected lines thru an external filter program | | " key | Select which cut buffer to use next | | count # key | Increment a number | | $ | Move to the rear of the current line | | count % | Move to matching (){}[] or to a given % of file | | count & | Repeat the previous ":s//" command here | | ' key | Move to a marked line | | count ( | Move backward "count" sentences | | count ) | Move forward "count" sentences | | * | Go to the next error in the errlist | | count + | Move to the front of the next line | | count , | Repeat the previous [fFtT] but in the other direction| | count - | Move to the front of the preceding line | | count . | Repeat the previous "edit" command | | / text | Search forward for a given regular expression | | 0 | If not part of count, move to 1st char of this line | | 1 | Part of a count argument | | 2 | Part of a count argument | | 3 | Part of a count argument | | 4 | Part of a count argument | | 5 | Part of a count argument | | 6 | Part of a count argument | | 7 | Part of a count argument | | 8 | Part of a count argument | | 9 | Part of a count argument | | : text | Run single EX cmd | | count ; | Repeat the previous [fFtT] cmd | | < mv | Shift text left | | = mv | Reformat | | > mv | Shift text right | | ? text | Search backward for a given regular expression | | @ key | Execute the contents of a cut-buffer as VI commands | | count A inp | Append at end of the line | | count B | Move back Word | | C inp | Change text from the cursor to the end of the line | | D | Delete text from the cursor to the end of the line | | count E | Move end of Word | | count F key | Move leftward to a given character | | count G | Move to line #"count" (default is the bottom line) | | count H | Move to home row (the line at the top of the screen) | | count I inp | Insert at the front of the line (after indents) | | count J | Join lines, to form one big line | | K | Run keywordprg on the word at the cursor | | count L | Move to last row (i.e., line at bottom of window) | | M | Move to middle row | | N | Repeat previous search, but in the opposite direction| | count O inp | Open up a new line above the current line | | P | Paste text before the cursor | | Q | Quit to EX mode | | R inp | Overtype | | count S inp | Change lines, like "count" cc | | count T key | Move leftward *almost* to a given character | | U | Undo all recent changes to the current line | | V | Start marking lines for c d y < > or ! | | count W | Move forward "count" Words | | count X | Delete the character(s) to the left of the cursor | | count Y | Yank text line(s) (copy them into a cut buffer) | | Z Z | Save the file & exit | | [ [ | Move back 1 section | | [ key | Start recording keystrokes into a cut-buffer | | \ | (undefined) | | ] ] | Move forward 1 section | | ] key | Stop recording keystrokes into a cut-buffer | | ^ | Move to the front of the current line (after indent) | | count _ | (the underscore character) Move to the current line | | ` key | Move to a marked character | | count a inp | Insert text after the cursor | | count b | Move back "count" words | | c mv | Change text | | d mv | Delete text | | count e | Move forward to the end of the current word | | count f key | Move rightward to a given character | | g | (undefined) | | count h | Move left | | count i inp | Insert text at the cursor | | count j | Move down | | count k | Move up | | count l | Move right | | m key | Mark a line or character | | n | Repeat the previous search | | count o inp | Open a new line below the current line | | p | Paste text after the cursor | | q | (undefined) | | count r key | Replace "count" chars by a given character | | count s inp | Replace characters, like "count" cl | | count t key | Move rightward *almost* to a given character | | count u | Undo the previous edit command | | v | Start marking characters for c d y < > or ! | | count w | Move forward "count" words | | count x | Delete the character that the cursor's on | | y mv | Yank text (copy it into a cut buffer) | | z key | Scroll current line to window's +top -bottom .middle | | count { | Move back "count" paragraphs | | count | | Move to column "count" (defaulting to column 1) | | count } | Move forward "count" paragraphs | | count ~ | Switch a character between uppercase & lowercase | | DEL | (undefined) | ^--------------^------------------------------------------------------^