&Erlend.Hamberg; &Erlend.Hamberg.mail;
The VI Input ModeVI Input ModeThe goal of the VI mode is not to be a complete replacement
for Vim and support all Vim’s features. Its aim is to make
the Vim way of text editing - and the Vim habits learned -
available for programs using the &kappname; text editor as their internal editor.The VI mode aims integrate nicely with the programs and deviate
from Vim’s behavior where it makes sense. For example,
:w will open a save dialog in &kappname;’s VI mode.To enable the VI input mode for all new views, go to
SettingsConfigure &kappname;...EditingVI Input Mode.
On this tab you can set options for the VI Input Mode and define and edit
the key mapping in this mode.
VI Input Mode can also be toggled with the VI Input Mode
setting in the Edit menu. (The default shortcut key is
Meta&Ctrl;V
- where Meta usually is the Windows key).Many Vi Mode keyboard commands are case-sensitive, unlike most &kde;
keyboard shortcuts. That means that y and
Y are different commands. To enter the
y (yank) command, make sure Caps Lock is
disabled and press Y. To enter the Y
(yank to end of line) command,
&Shift;Y.This does not apply to commands that use the &Ctrl; key, which may be
entered regardless of Caps Lock mode and without pressing
&Shift;. However, some commands require the use of &Ctrl;-key combination
followed by another key which is case sensitive. For instance, to input
&Ctrl;W,
h (switch to split view right) make sure
Caps Lock is disabled, press
&Ctrl;W, release, and
then press H.Incompatibilities with VimThere are only a few features of &kappname;’s VI mode which are incompatible
with Vim (not counting things missing). They are listed below together
with the respective reasons.&kappname;: U and
&Ctrl;R is redo.Vim: &Ctrl;R is
normal redo, U is used to undo all latest changes on one line.The reason for having U act as redo in &kappname;’s VI mode is
that the shortcut &Ctrl;R
by default is taken by &kappname;’s replace function (search and replace). By default,
the VI mode won’t override &kappname;’s shortcuts (this can be configured in
SettingsConfigure &kappname;...EditingVi Input Mode),
therefore a redo-action needs to be available as a regular key press, too.
Besides, the behavior of the U command in Vim does not map well
to &kappname;’s internal undo system, so it would be non-trivial to support anyway.&kappname;: print shows the Print dialog.Vim: print prints the lines of
the given range like its grandfather ed.Commands like :print are available
not only in the VI mode but for users using regular &kappname;, too - therefore
the :print command opens
the print dialog - following the principle of least surprise instead of
mimicking Vim’s behavior.&kappname;: Y yanks to end of line.Vim: Y yanks whole line, just like
yy.VI’s behavior for the Y command is in practice a bug.
For both change and delete commands,
cc/
dd will do its action on
the current line and C/D will work from the
cursor column to the end of the line. However, both
yy and Y
yanks the current line. In &kappname;’s VI Mode Y will yank to the end
of the line. This is described as more logical in the Vim
documentation.
&kappname;: O and o opens [count] new lines
and puts you in insert mode.Vim: O and o opens a new line and inserts
text [count] times when leaving insert mode.This is mostly done as a consequence of witnessing many people being
confused by this behavior on a vim irc channel (#vim on freenode).Switching ModesNormal Mode permits you to enter commands to navigate or edit
a document, and is the default mode. You can return to it from any other mode by
pressing &Esc;.
Visual Mode permits you to highlight text in a document.
Most Normal Mode commands are also valid in this mode. You can enter it by pressing
v to select characters or V to select lines.
Insert Mode permits you to edit the document directly. You
can enter it by pressing i or one of several other commands
listed below.
Command Mode invokes &kappname;'s command line,
permitting you to run many commands available in Vi implementations as well as
some specific to &kappname;. For more information on these commands, see
. To use it,
press :, enter the command, and press &Enter;.Integration with Kate featuresVisual Mode is entered automatically when text is selected with the mouse.
It is also entered when using functions of Kate that select text, such as Select
All (either from the menu or via &Ctrl;A.)Vi marks and Kate bookmarks are
integrated. When a mark is created in Vi Mode, a corresponding Kate bookmark is
created and appears in the Bookmarks menu. Conversely, when
a Kate bookmark is created, a corresponding Vi mark at the 0 column is also
created.Supported normal/visual mode commandsaEnter Insert Mode; append after cursorAEnter Insert Mode; append after lineiEnter Insert Mode; insert before cursorvEnter Visual Mode; select charactersVEnter Visual Mode; select linesoOpen a new line below current lineOOpen a new line above current lineJJoin linescChange: follow by a motion to delete and enter Insert modeCChange to end of line: Delete to end of line and enter Insert ModeccChange line: Delete line and enter Insert ModesSubstitute characterSSubstitute lineddDelete linedFollow by a motion to deleteDDelete to end of linexDelete character to right of cursorXDelete character to left of cursorguFollow with a motion to make lowercasegMake the current line lowercasegUFollow with a motion to make uppercasegMake the current line uppercaseyFollow by a motion to yank (copy)yyYank (copy) lineYYank (copy) linepPaste after cursorPPaste before cursorrFollow with a character to replace the character after the cursor:Enter Command Mode/SearchuUndo&Ctrl;RRedoURedomSet mark (can be used by motions later)nFind nextNFind previous>>Indent line<<Unindent line>Indent lines<Unindent lines&Ctrl;FPage down&Ctrl;BPage upgaPrint the ASCII value of the character.Repeat last change==commandAlignLine=commandAlignLines~Change case of current character&Ctrl;SSplit view horizontally&Ctrl;VSplit view vertically&Ctrl;
W, wCycle to next split window&Ctrl;
W, h&Ctrl;
WLeftGo to left split window&Ctrl;
W, l&Ctrl;
WRightGo to right split window&Ctrl;
W, k&Ctrl;
WUpGo to above split window&Ctrl;
W, j&Ctrl;
WDownGo to below split windowSupported motionsThese may be used to move around a document in Normal or Visual mode, or in
conjunction with one of the above commands. They may be preceded by a count,
which indicates how many of the appropriate movements to make.hLeftLeftLeft&Backspace;LeftjDownDownDownkUpUpUplRightRightRightSpaceRight$End of lineEndEnd of line0First character of line (Column 0)HomeFirst character of line^First non-blank character of linefFollow by character to move to right of cursorFFollow by character to move to left of cursortFollow by character to move to right of cursor, placing the cursor on character before itTFollow by character to move to left of cursor, placing the cursor on character before itggFirst lineGLast linewNext WordWNext word separated by whitespacebPrevious wordBPrevious word separated by whitespaceeEnd of wordEEnd of word separated by whitespacegeEnd of previous wordgEEnd of previous word separated by whitespace|Follow by a column number to move to that column%Follow by an item to move to that item`Mark‘First non-whitespace character of the line the mark is on[[Previous opening bracket]]Next opening bracket[]Previous closing bracket][Next closing bracket&Ctrl;IJump forward to next location&Ctrl;OJump back to previous locationHGo to first line of screenMGo to middle line of screenLGo to last line of screen%percentageGo to specified percentage of the documentgkGo one line up visually (when using dynamic word wrap)gjGo one line down visually (when using dynamic word wrap)Supported text objectsThese may be used to select certain portions of a document.iwInner word: word including whitespaceawA word: word excluding whitespacei"Previous double-quote (") to next double-quote,
including quotation marksa”Previous double-quote (") to next double-quote,
excluding quotation marksi'Previous single-quote (') to next single-quote,
including quotation marksa'Previous single-quote (') to next single-quote,
excluding quotation marksi(Previous opening parenthesis [(] to next closing
parenthesis [)], including the parenthesisa(Previous opening parenthesis [(] to next closing
parenthesis [)], excluding the parenthesisi[Previous opening square bracket ([) to next closing
square bracket (]), including the bracketsa[Previous opening square bracket ([) to next closing
square bracket (]), excluding the bracketsi{Previous opening curly bracket ({) to next closing
curly bracket (}), including the bracketsa{Previous opening curly bracket ({) to next closing
curly bracket (}), excluding the bracketsi<Previous opening angle bracket (<) to next closing
angle bracket (>), including the bracketsa<Previous opening angle bracket (<) to next closing
square bracket (>), excluding the bracketsi`Previous backtick (`) to next backtick,
including the backticksa`Previous backtick (`) to next backtick,
excluding the backticksSupported insert mode commands&Ctrl;DUnindent&Ctrl;TIndent&Ctrl;EcommandInsertFromBelow&Ctrl;YDelete word&Ctrl;WDelete word&Ctrl;HomeMove to first character in the document&Ctrl;RnInsert the contents of register n&Ctrl;O,
commandEnter normal mode for one command only&Ctrl;AIncrement currently selected number&Ctrl;XDecrement currently selected numberThe Comma Text ObjectThis object is missing in Vim. The comma text object
makes it easy to modify parameter lists in C-like languages and other comma
separated lists. It is basically the area between two commas or between a comma
and a bracket. In the line shown in the illustration to the right, the three
ranges this text object can span are highlighted in red.An example of Comma Text ObjectAn example of Comma Text Object
Comma text object ranges. If the cursor is over ⪚
arg2, pressing
ci, (change inner comma)
would delete double arg2 and place the cursor between
the two commas in insert mode. A very convenient way to change a function's
parameters.
Missing FeaturesAs stated earlier, the goal of &kappname;’s VI Mode is not to support 100% of
Vim’s features, however, there are some features which are sorely missed:Visual block mode - especially the ability to prepend/append text to the
visual block selection.Having ex commands available in other programs than the &kappname; application.The search code needs improvement and the * and
#commands should just be regular searches.