Skip to content
Newer
Older
100644 200 lines (174 sloc) 9.12 KB
2570a7f @ehamberg import some posts from old blog
authored
1 ---
2 title: The Vi input mode for Kate is “done”
3 description: The original goals set for Kate's Vi input mode are now completed
4 tags: gsoc, kate, programming
5 ---
6
7 <div style="border: 1px solid black; margin: 0pt auto -1px; padding: 1em; background-color: #eeeeee; width: 50%; text-align: center;">Please see [http://hamberg.no/erlend/kate-vi-mode/](http://hamberg.no/erlend/kate-vi-mode/) for an updated overview of the Kate VI mode project.</div>
8
9 I just marked the Vi input mode ("V.I.M."? :) ) for the Kate kpart as done in
10 the feature plan for [KDE
11 4.2](http://techbase.kde.org/Schedules/KDE4/4.2_Feature_Plan). It feels a bit
12 weird to mark it as done, though, as there are tonnes of things I want to
13 implement after KDE 4.2.
14
15 As you may know this started as a [Google Summer of Code
16 project](http://code.google.com/soc/2008/kde/appinfo.html?csaid=370F903C96FF67D1)
17 and I'm quite happy with the way things have turned out. Since we are in feature
18 freeze I would like to present the features that will be in the Vi input mode
19 for the Kate part in KDE 4.2.
20
21 ![Kate Vi Input Mode in action -- visual mode selection](/images/vimode1.png)
22
23 The Vi input mode can be used as the default editing mode by selecting it in
24 `Settings``Configure Kate...``Editing``Vi Input Mode` and/or toggled
25 any time by selecting ~~`View`~~`Edit``Vi Input Mode`. Nifty, eh?
26
27 ![Vi Input Mode toggle](/images/vimode2.png)
28
29 Thanks to [Dmitry Suzdalev](http://dimsuz.wordpress.com/) there is also an
30 (optional) vi mode status bar. This shows commands while they are being entered,
31 output from commands like `ga` (the character code of the character under the
32 cursor) and of coruse the current mode.
33
34 ![Kate Vi Input mode status bar -- "a4d has been pressed](/images/vimode3.png)
35
36 Quite a few of the vi commands collide with "regular" Kate shortcuts, like
37 **ctrl+b**/**ctrl+f** for scrolling up/down one page. If you want to use these
38 as vi commands, you can choose to let Vi commands override Kate shortcuts in the
39 Vi input mode settings. As you might know, **ctrl+r** is used for "redo" in vim.
40 To make it possible to redo for people not wanting to override Kate's shortcuts
41 **shift+u** is also used for undo. (This key press is used for "undoing all
42 latest changes on one line" in Vim.)
43
44 I have also added support for ranges to Kate's command line commands. So you can
45 do **1,10kill-line** ("kill-line" is a Kate command, not a vi(m) command). This
46 also works for the substitute command which is already a part of Kate:
47 **s/foo/bar/g**. This is something whose potential hopefully will be fully
48 exploited in the future when more commands are added.
49
50 For now, the only "ex commands" supported are **:w** and **:hardcopy**. Part of
51 the reason not more commands are supported is because I need to figure out how
52 to send requests from the editor part to the hosting application requesting to
53 e.g. quit or close a buffer. I also want to be able to add several forms of
54 commands like **:d[elete]**, **:w[rite]** and so on. (But only the long form
55 should be shown in the autocompletion to not clutter the dropdown with confusing
56 one-letter commands.)
57
58 But, enough of what's not supported! Here is the list of the commands that
59 actually made it into the Vi Input Mode before the feature freeze:
60
61 ### Supported normal/visual mode commands
62
63 Keypress(es) Action
64 ------------------ ---------------------------------
65 `a` `commandEnterInsertModeAppend`
66 `A` `commandEnterInsertModeAppendEOL`
67 `i` `commandEnterInsertMode`
68 `v` `commandEnterVisualMode`
69 `V` `commandEnterVisualLineMode`
70 `o` `commandOpenNewLineUnder`
71 `O` `commandOpenNewLineOver`
72 `J` `commandJoinLines`
73 `c` `commandChange`
74 `C` `commandChangeToEOL`
75 `cc` `commandChangeLine`
76 `s` `commandSubstituteChar`
77 `S` `commandSubstituteLine`
78 `dd` `commandDeleteLine`
79 `d` `commandDelete`
80 `D` `commandDeleteToEOL`
81 `x` `commandDeleteChar`
82 `X` `commandDeleteCharBackward`
83 `gu` `commandMakeLowercase`
84 `guu` `commandMakeLowercaseLine`
85 `gU` `commandMakeUppercase`
86 `gUU` `commandMakeUppercaseLine`
87 `y` `commandYank`
88 `yy` `commandYankLine`
89 `Y` `commandYankToEOL`
90 `p` `commandPaste`
91 `P` `commandPasteBefore`
92 `r` `commandReplaceCharacter`
93 `:` `commandSwitchToCmdLine`
94 `/` `commandSearch`
95 `u` `commandUndo)`
96 `<c-r>` `commandRedo`
97 `U` `commandRedo`
98 `m.` `commandSetMark`
99 `n` `commandFindNext`
100 `N` `commandFindPrev`
101 `>>` `commandIndentLine`
102 `<<` `commandUnindentLine`
103 `>` `commandIndentLines`
104 `<` `commandUnindentLines`
105 `<c-f>` `commandScrollPageDown`
106 `<c-b>` `commandScrollPageUp`
107 `ga` `commandPrintCharacterCode`
108 `.` `commandRepeatLastChange`
109 `==` `commandAlignLine`
110 `=` `commandAlignLines`
111 `~` `commandChangeCase`
112
113 ### Supported motions
114
115 Keypress(es) Action
116 ------------------ ---------------------------------
117 `h` `motionLeft`
118 `<left>` `motionLeft`
119 `<backspace>` `motionLeft`
120 `j` `motionDown`
121 `<down>` `motionDown`
122 `k` `motionUp`
123 `<up>` `motionUp`
124 `l` `motionRight`
125 `<right>` `motionRight`
126 `<space>` `motionRight`
127 `$` `motionToEOL`
128 `<end>` `motionToEOL`
129 `0` `motionToColumn0`
130 `<home>` `motionToColumn0`
131 `^` `motionToFirstCharacterOfLine`
132 `f` `motionFindChar`
133 `F` `motionFindCharBackward`
134 `t` `motionToChar`
135 `T` `motionToCharBackward`
136 `gg` `motionToLineFirst`
137 `G` `motionToLineLast`
138 `w` `motionWordForward`
139 `W` `motionWORDForward`
140 `b` `motionWordBackward`
141 `B` `motionWORDBackward`
142 `e` `motionToEndOfWord`
143 `E` `motionToEndOfWORD`
144 `ge` `motionToEndOfPrevWord`
145 `gE` `motionToEndOfPrevWORD`
146 `|` `motionToScreenColumn`
147 `%` `motionToMatchingItem`
148 ` `motionToMark`
149 `'` `motionToMarkLine`
150 `[[` `motionToPreviousBraceBlockStart`
151 `]]` `motionToNextBraceBlockStart`
152 `[]` `motionToPreviousBraceBlockEnd`
153 `][` `motionToNextBraceBlockEnd`
154
155 ### Supported text objects
156
157 Keypress(es) Action
158 ------------------ ---------------------------------
159 `iw` `textObjectInnerWord`
160 `aw` `textObjectAWord`
161 `i"` `textObjectInnerQuoteDouble`
162 `a"` `textObjectAQuoteDouble`
163 `i'` `textObjectInnerQuoteSingle`
164 `a'` `textObjectAQuoteSingle`
165 `i(` `textObjectInnerParen`
166 `a(` `textObjectAParen`
167 `i[` `textObjectInnerBracket`
168 `a[` `textObjectABracket`
169
170 ### Supported insert mode commands
171
172 Keypress(es) Action
173 ------------------ ---------------------------------
174 `<c-d>` `commandUnindent`
175 `<c-t>` `commandIndent`
176 `<c-e>` `commandInsertFromBelow`
177 `<c-y>` `commandInsertFromAbove`
178 `<c-w>` `commandDeleteWord`
179 `<c-home>` `commandToFirstCharacterInFile`
180
181 ### The missing pieces
182
183 The aim of Kate's Vi input mode is--as I have said before--is not to replace vim's
184 functionality, but to have a editor kpart that is comfortable to use for us
185 Vi(m)-heads. There are however some things I feel is still missing and would
186 like to implement after KDE 4.2 (some of them mentioned above):
187
188 - Proper command mode ("ex commands") support (very few commands are supported as of now)
189 - Saving of registers and marks between editing sessions
190 - "Replace mode" (`shift+r` in vim)
191 - Integrating the Vi input mode marks with Kate's bookmarks system
192 - Making it possible to use registers in ranges and add support for the the `'<` and `'>` registers
193
194 ### Please test!
195
196 I will be studying for my exams until 19 December so I won't have much time for
197 coding, but I would still like people to test the Vi Input Mode and report bugs
198 so I have a better chance of fixing them before the end of January and the 4.2
199 release.
Something went wrong with that request. Please try again.