מצב VI
הקדמה

Kate's VI mode is a project to bring Vim-like, modal editing to the Kate text editor and by extension to other KDE programs who share the same editor component. The project started as a Google Summer of Code project in 2008 – where all the basic functionality was written. I have continued to maintain and further develop this code and the number of missing features from Vim are slowly decreasing. Most Vim users will already be productive in Kate's VI mode. A list of what's missing is found at the bottom of the page.
This page is meant to be an updated overview of this work.
Settings → Configure Kate… → Editing → VI Input Mode.
It 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).
יעדים
The 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 Kate text editor as their internal editor. These programs include
- עורך הטקסט Kate
- KWrite – עורך הטקסט הפשוט של KDE
- KDevelop – סביבת פיתוח משולבת מתקדמת למגוון רחב של שפות תכנות
- Kile – עורך לאטך/LaTeX
The VI mode aims integrate nicely with the programs and deviate from Vim's behaviour where it makes sense. For example, :w will open a save dialogue in Kate's VI mode.
לקויות תאימות מול Vim
There are only a few features of Kate's VI mode which are incompatible with Vim (not counting things missing). They are listed below together with the respective reasons.
- Kate:
UandCtrl+ris redo
Vim:Ctrl+ris normal redo,Uis used to undo all latest changes on one line
The reason for havingUact as redo in Kate's VI mode is that the shortcutctrl+rby default is taken by Kate's replace function (search and replace). By default, the VI mode won't override Kate's shortcuts (this can be configured in Settings → Configure Kate… → Editing → Vi Input Mode), therefore a redo-action needs to be available as a “regular” key press, too. Besides, the behaviour of the U command in Vim doesn't map well to Kate's internal undo system, so it would be non-trivial to support anyway. - Kate:
:printshows the "print" dialogue
Vim::printprints 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” Kate, too – I have therefore chosen to let the:printcommand open the print dialogue – following the principle of least surprise instead of mimicking Vim's behaviour. - Kate:
Yyanks to end of line.
Vim:Yyanks whole line, just likeyy. VI's behaviour for theYcommand is in practice a bug; For both change and delete commands,cc/ddwill do its action on the current line andC/Dwill work from the cursor column to the end of the line. However, bothyyandYyanks the current line.In Kate's VI ModeYwill yank to the end of the line. This is described as "more logical" in the Vim documentation. - Kate:
:mapalters the selected lines of the document using the provided JavaScript expression.
Vim::mapadds the provided mapping to Normal and Visual modes. The "map" command was already reserved by Kate; in 4.12+, you can use a combination of:nmapand:vmapto replace it.
פקודות נתמכות
Supported normal/visual mode commands
| מקש | תיאור |
|---|---|
| a | כניסה למצב כתיבה והוספה לסוף |
| A | כניסה למצב כתיבה והוספה לסוף השורה |
| i | כניסה למצב כתיבה |
| I | כתיבה לפני התו הראשון שאינו ריק בשורה |
| v | כניסה למצב חזותי |
| V | כניסה למצב שורות חזותי |
| <c-v> | כניסה למצב מקטעים חזותי |
| gv | בחירה חזותית מחדש |
| o | פתיחת שורה חדשה מתחת |
| O | פתיחת שורה חדשה מעל |
| J | צירוף שורות |
| c | שינוי |
| C | שינוי לסוף השורה |
| cc | שינוי שורה |
| s | החלפת תו |
| S | החלפת שורה |
| dd | מחיקת שורה |
| d | מחיקה |
| D | מחיקה עד סוף השורה |
| x | מחיקת תו |
| X | מחיקת תו אחורה |
| gu | המרה לאותיות קטנות |
| guu | המרת השורה לאותיות קטנות |
| gU | המרה לאותיות גדולות |
| gUU | המרת השורה לאותיות גדולות |
| y | שליפה |
| yy | שליפת שורה |
| Y | שליפה לסוף השורה |
| p | הדבקה |
| P | הדבקה לפני |
| r. | החלפת תו |
| R | כניסה למצב החלפה |
| : | מעבר לשורת פקודות |
| / | חיפוש |
| u | הסגה |
| <c-r> | ביצוע מחדש |
| U | ביצוע מחדש |
| m. | הגדרת סמן |
| >> | הגדלת הזחת שורה |
| << | הקטנת הזחת שורה |
| > | הגדלת הזחת שורות |
| < | הקטנת הזחת שורות |
| <c-f> | גלילת עמוד אחד למטה |
| <pagedown> | גלילת עמוד אחד למטה |
| <c-b> | גלילת עמוד אחד למעלה |
| <pageup> | גלילת עמוד אחד למעלה |
| <c-u> | גלילת חצי עמוד למעלה |
| <c-d> | גלילת חצי עמוד למטה |
| zz | מרכוז התצוגה סביב הסמן |
| ga | הדפסת קוד תו |
| . | חזרה על השינוי האחרון |
| == | יישור שורה |
| = | יישור שורות |
| ~ | החלפת מצב רישיות (גדולות/קטנות) |
| <c-a> | הוספה למספר |
| <c-x> | חיסור מהמספר |
| <c-o> | מעבר לקפיצה הקודמת |
| <c-i> | מעבר לקפיצה הבאה |
| <c-w>h | מעבר לתצוגה השמאלית |
| <c-w><c-h> | מעבר לתצוגה השמאלית |
| <c-w><שמאלה> | מעבר לתצוגה השמאלית |
| <c-w>j | מעבר לתצוגה התחתונה |
| <c-w><c-j> | מעבר לתצוגה התחתונה |
| <c-w><למטה> | מעבר לתצוגה התחתונה |
| <c-w>k | מעבר לתצוגה העליונה |
| <c-w><c-k> | מעבר לתצוגה העליונה |
| <c-w><למעלה> | מעבר לתצוגה העליונה |
| <c-w>l | מעבר לתצוגה הימנית |
| <c-w><c-l> | מעבר לתצוגה הימנית |
| <c-w><ימינה> | מעבר לתצוגה הימנית |
| <c-w>w | מעבר לתצוגה הבאה |
| <c-w><c-w> | מעבר לתצוגה הבאה |
| <c-w>s | פיצול אופקי |
| <c-w>S | פיצול אופקי |
| <c-w><c-s> | פיצול אופקי |
| <c-w>v | פיצול אנכי |
| <c-w><c-v> | פיצול אנכי |
| gt | מעבר ללשונית הבאה |
| gT | מעבר ללשונית הקודמת |
| gqq | עיצוב שורה |
| gq | עיצוב שורות |
| q. / q | התחלת / סיום הקלטת מאקרו עם רשומת המאקרו השמית. |
תנועות נתמכות
| מקש | תיאור |
|---|---|
| h | שמאלה |
| <שמאלה> | שמאלה |
| <backspace> | שמאלה |
| j | למטה |
| <למטה> | למטה |
| <enter> | ירידה למה שלא ריק |
| k | למעלה |
| <למעלה> | למעלה |
| – | עלייה למה שלא ריק |
| l | ימינה |
| <ימינה> | ימינה |
| <רווח> | ימינה |
| $ | לסוף השורה |
| <end> | לסוף השורה |
| לעמודה 0 | |
| <home> | לעמודה 0 |
| ^ | לתו הראשון בשורה |
| f. | איתור תו |
| F. | איתור תו אחורה |
| t. | לתו |
| T. | לתו אחורה |
| ; | חזרה על פעולת ה־t. או ה־f. האחרונה |
| , | חזרה על פעולת ה־t. או ה־f. האחרונה |
| n | איתור הבא |
| N | איתור הקודם |
| gg | לשורה הראשונה |
| G | לשורה האחרונה |
| w | מילה קדימה |
| W | מילה (באותיות גדולות) קדימה |
| b | מילה אחורה |
| B | מילה (באותיות גדולות) אחורה |
| e | לסוף מילה |
| E | לסוף מילה (באותיות גדולות) |
| ge | לסוף המילה הקודמת |
| gE | לסוף המילה (באותיות גדולות) הקודמת |
| % | לפריט התואם |
| `[a-zA-Z><] | לסימן |
| '[a-zA-Z><] | לסימון שורה |
| [[ | להתחלת המקטע הקודם שבסוגריים |
| ]] | להתחלת המקטע הבא בסוגריים |
| [] | לסוף המקטע הקודם שבסוגריים |
| ][ | לסוף המקטע הבא בסוגריים |
| * | למופע הבא של המילה שתחת הסמן |
| # | למופע הקודם של המילה שתחת הסמן |
| H | לשורה הראשונה בחלון |
| M | לשורה האמצעית בחלון |
| L | לשורה האחרונה בחלון |
| gj | לשורה החזותית הבאה |
| gk | לשורה החזותית הקודמת |
עצמי הטקסט הנתמכים
| מקש | תיאור |
|---|---|
| iw | מילה פנימית |
| aw | מילה |
| iW | מילה (באותיות גדולות) פנימית |
| aW | מילה (באותיות גדולות) |
| i" | מירכאות כפולות פנימיות |
| a" | מירכאות כפולות |
| i’ | מירכה פנימית בודדת |
| a’ | מירכה בודדת |
| i` | גרש הפוך פנימי |
| a` | גרש הפוך |
| ib | סוגריים פנימיים |
| i) | סוגריים פנימיים |
| i( | סוגריים פנימיים |
| ab | סוגריים |
| a) | סוגריים |
| a( | סוגריים |
| iB | סוגריים מסולסלים פנימיים |
| o} | סוגריים מסולסלים פנימיים |
| i{ | סוגריים מסולסלים פנימיים |
| aB | סוגריים מסולסלים |
| a} | סוגריים מסולסלים |
| a{ | סוגריים מסולסלים |
| i< | סימן אי שוויון פנימי |
| i> | סימן אי שוויון פנימי |
| a< | סימן אי שוויון |
| a> | סימן אי שוויון |
| i[ | סוגר מרובע פנימי |
| I] | סוגר מרובע פנימי |
| a[ | סוגר מרובע |
| a] | סוגר מרובע |
| i, | פסיק פנימי |
| a, | פסיק |
פקודות מצב כתיבה נתמכות
| מקש | תיאור |
|---|---|
| <c-d> | הקטנת הזחת שורה |
| <c-t> | הגדלת הזחה |
| <c-e> | הוספה מלמטה |
| <c-y> | הוספה מלמעלה |
| <c-w> | מחיקת מילה |
| <c-r>. | הוספת תוכן רשומה |
| <c-o> | מעבר למצב רגיל לפקודה אחת |
| <c-a> | הגדלת המספר שתחת הסמן |
| <c-x> | הקטנת המספר שתחת הסמן |
עצם טקסט שתחום בפסיק
This is something that I have been 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.

Comma text object ranges. If the cursor is over, say, “arg2”, pressing c i , (“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.
סרגל פקודות Vim מדומה
Kate 4.11 introduced a hidden config option that make /, ? and : bring up a new search/ command in place of the usual Kate Find / Replace / Command-line bar. The bar is intended to replicate many of the features of Vim's command bar, and also to fix many of the issues with Kate Vim mode's interaction with Kate's Find/Replace bar (interactive replace not working; incremental search not positioning the cursor correctly; not usable in mappings/macros; etc).
The following shortcuts are provided by the emulated command bar; as with Vim, these can be remapped with cmap, cnoremap, etc:
| מקש | תיאור |
|---|---|
| <c-r>. | הוספת תוכן רשומה. |
| <c-r><c-w> | הוספת מילה תחת סמן (המסמך). |
| <c-p> | Invoke context-specific completion (see below) move back/ up in the completion list. |
| <c-p> | Move forward/ down in the completion list. |
| <c-רווח> | Kate Vim Extension. Auto-complete word from document. |
| <c-d> | Kate Vim Extension. In a sed-replace expression (i.e. s/find/replace/[g][c][i]), clear the "find" term and place the cursor there. |
| <c-f> | Kate Vim Extension. In a sed-replace expression (i.e. s/find/replace/[g][c][i]), clear the “replace” term and place the cursor there. |
| <c-g>. | הרחבות Vim ל־Kate. כמו עם ., להוסיף את תוכן הרשומה בעלת השם, אבל למלט (escape) אותה בדרך שכשמשתמשים בה בחיפוש, אנו מחפשים את התוכן של הרשומה בפועל, לא את התוכן של הרשומה בפענוח לביטויים רגולריים. |
ה„השלמה לפי הקשר” נקבעת לפי התנאים הבאים:
- בסרגל חיפוש (
/או?), השלמה אוטומטית מהיסטוריית החיפוש (שכוללת חיפושים שהופעלו דרך*ו־#, חיפושים שבוצעו בביטויי החלפה של sed וכו׳.) - In an empty command bar (
:), auto-complete from command history (NB: auto-completion of command names is invoked automatically when you begin typing). - In a command-bar containing a sed-replace expression (e.g.
:s/find/replace/gc), if the cursor is positioned over "find", auto-complete from the "search" history; if over the "replace", auto-complete from the history of "replace" terms.
When executing a sed-replace expression in the command bar with the "c" flag (e.g. s/find/replace/gc), a Vim-style interactive search/replace expression will be initiated.
Some example usages of the emulated command bar, with GIF animations, are given in this blog. In 4.11, the emulated command bar can be enabled by setting the hidden config option "Vi Input Mode Emulate Command Bar" to true in your katerc/kwriterc/kdeveloprc.
Missing Features
As stated earlier, the goal of Kate'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 Kate application.
- The search code needs improvement and the * and # commands should just be regular searches.
If you miss other features or want to help on the ones mentioned above, feel free to contact me or send patches! :-)
יומן שינויים
- 2010-05-16:
Initial version. Collected the information from blog entries and README files to make a single source of current information. - 2010-05-17:
Ctrl+AandCtrl+Xadded (increment/decrement number under cursor). - 2010-08-30:
Moved page to kate-editor.org. - 2010-09-10:
Fixed the text on the comma text object and made some formatting fixes - 2021-02-03:
Converted key-binding tables to markdown for hugo.