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.
Each type of text object has a two-character name. The first character is 'a' for the whole object including surrounding text, or 'i' for just the "inner" part of the object without any surrounding text. The second character describes how the object's endpoints are to be found.
.----------.-----------------------------------------------------. | 2nd char | Extent of the text object | |----------|-----------------------------------------------------| | w | word or punctuation string, like b e w commands | | W | whitespace-delimited word, like B E W commands | | s | sentence, like ( ) commands | | p | paragraph, like { } commands | | S | section, like [[ ]] commands | | { [ ( < | block delimited by the previous {[(< and its match | | } ] ) > | block delimited by the following }])> and its match | | % | block delimited by any of {[( and its match | | b | block delimited by parentheses, like a( or i( | | B | block delimited by braces, like a{ or i{ | | L | group of lines with same or greater indentation | | l | individual lines (i.e. fields delimited by newlines)| | t | field, delimited by tabs | | other | field, delimited at both ends by the character or \n| ^----------^-----------------------------------------------------^
The use of uppercase S
for sections,
%
for any brace-delimited block,
L
for an indentation-delimited block,
l
for lines,
and other punctuation for field delimiters
are all extensions beyond vim's text objects.
For block text objects, the 'a' version includes the delimiting characters, while the 'i' version excludes them. The "aL" object includes surrounding blank lines, while "il" excludes those lines plus the leading whitespace of the first line the trailing newline of the last line. For field text objects, the 'a' version includes the trailing delimiter but not the leading one, while the 'i' version omits both delimiters and any leading whitespace. For the other text objects, the 'a' version includes trailing whitespace (or leading whitespace if there is no trailing whitespace), and the 'i' version is just the object itself without the surrounding whitespace.
Text objects accept counts.
For blocks, the count is the number of levels of embedded brackets to skip.
For fields, the count is the number of delimiters to skip in both directions, so a count of n selects 2n-1 objects centered around the cursor.
For other text objects, the count is the number of consecutive objects
to use, starting with the current one.
For example, "3daw
" deletes three words,
while "3dab
" moves outward three levels of parentheses
and then deletes that single large block.
"3dal
" deletes five lines centered around the cursor.
.--------------.------------------------------------------------------. | COMMAND | DESCRIPTION | |--------------|------------------------------------------------------| | P | Paste text before the cursor | | p | Paste text after the cursor | | count J | Join lines, to form one big line | | count gJ | Join lines without adding whitespace | | 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 gI inp | Input at start of line (before 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) | | g= key mv | Convert text to uppercase | | gU mv | Convert text to uppercase | | gu mv | Convert text to lowercase | | g~ mv | Toggle text between uppercase & lowercase | ^--------------^------------------------------------------------------^These commands all affect text between the cursor's current position and some other position. There are four ways that you can specify that other position:
The "g" operators (g=, gU, gu, and g~) are only available if elvis has been compiled with FEATURE_G enabled. In arithmetic expressions you can use the feature("g") function to test for this.
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.
The difference between g~ and ~ is that g~ is an operator, while ~ simply changes the characters immediately without waiting for a motion or text object.
.--------------.------------------------------------------------------. | 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) | | g$ | Move to end of current row | | g0 | Move to start of current row, before indent | | g^ | Move to start of current row, after indent | | count gh | Move left, skipping invisible characters | | count gj | Move down 1 row (useful when lines wrap) | | count gk | Move up 1 row (useful when lines wrap) | | count gl | Move right, skipping invisible characters | ^--------------^------------------------------------------------------^
.--------------.------------------------------------------------------. | 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 | | gD | Go to global definition of word at cursor | | gd | Go to local definition 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. This also has the side-effect of making the search be line-oriented instead of character oriented; this affects the behavior of operators. Line deltas don't work when the incsearch option is set.
You can also append the following single-letter flags after the closing delimiter:
.------.-------------------------------------. | FLAG | MEANING | |------|-------------------------------------| | v | :set autoselect | | n | :set noautoselect | | c | :set noignorecase | | i | :set ignorecase nosmartcase | | s | :set ignorecase smartcase | | w | match whole words only (add \< \>) | | x | match whole lines only (add ^ $) | ^------^-------------------------------------^
.--------------.------------------------------------------------------. | 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 ! | | g% | If any text is selected, go to opposite end | | g^V | If a rectangle is selected, go to opposite edge | ^--------------^------------------------------------------------------^
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.
The vim clone of vi changes the meanings of some commands while text is selected. I didn't bother to do this with elvis because the :map command can be used to achieve the same effect. Vim users may want to try the following maps:
:map select r g= :map select x d :map select U gU :map select u gu :map select ~ g~ :map select J :j :map select ^] y:ta :map select R S :map select o g% :map select O g^V^V
.--------------.------------------------------------------------------. | 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 | (Tab) Go to next HTML link, or toggle folding | | g^I | (g-Tab) Go to previous HTML 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 | | count gs | Find next misspelled word, maybe after fixing current| | gS | Move to end of spelling word | ^--------------^------------------------------------------------------^
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.
Note: Most user interfaces try to map <Shift-Tab> to this command. This is difficult for the termcap interface because not all terminals support it. Even if the terminal supports it, the termcap/terminfo database might not describe it correctly.
If given a count, then before moving, try to replace the current misspelled word with the count'th suggested spelling. This only works if the show option contains a "spell" keyword, and the cursor is on a misspelled word with good suggestions. See the "Tips" chapter for more information about the spell checker.
.--------------.------------------------------------------------------. | 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) Go to next HTML link, or toggle folding | | 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) | | g^I | (g-Tab) Go to previous HTML link | | g^V | If a rectangle is selected, go to opposite edge | | g$ | Move to end of current row | | g% | If any text is selected, go to opposite end | | g0 | Move to start of current row, before indent | | g= key mv| Replace characters with key | | gD | Go to global definition of word at cursor | | count gI inp | Input at start of line, before indent | | count gJ | Join lines without adding whitespace | | gS | Move to end of spelling word | | gU mv | Convert text to uppercase | | g^ | Move to start of current row, after indent | | gd | Go to local definition of word at cursor | | count gh | Move left, skipping invisible characters | | count gj | Move down 1 row (useful when lines wrap) | | count gk | Move up 1 row (useful when lines wrap) | | count gl | Move right, skipping invisible characters | | count gs | Find next misspelled word, maybe after fixing current| | gu mv | Convert text to lowercase | | g~ mv | Toggle text between uppercase & lowercase | | 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) | ^--------------^------------------------------------------------------^