Vim Mode#
Vim is a keyboard-centric text editor. “Vim mode” refers to another editor implementing the ability to perform a subset of vim motions. This will allow you to write, select, edit, copy, paste, navigate, etc, efficiently by using keyboard commands.
Vim is modal. Three such modes have been implemented in novelWriter:
Normal mode is the default mode used to navigate text.
Insert mode is where you can write text like in a ‘normal’ text editor.
Visual mode is for selecting text, with:
Visual mode for per character selection.
V-Line mode for per-line selection.
The vim mode setting is found in the Features section of the Preferences.
Note
Vim mode is an advanced feature. When you enable it, the text editor will behave very differently than a standard text editor. A label in the footer of the editor will show which of the vim modes it is in.
Mode Switching#
To switch between the various vim modes, these keystrokes implemented:
From Mode |
To Mode |
Keystrokes |
|---|---|---|
Normal |
Insert |
i, I, a, A, o, O |
Insert |
Normal |
Esc |
Normal |
Visual |
v, V |
You can exit visual mode back to normal mode by pressing Esc, but all visual mode commands that logically “terminate” the visual mode usage will return you to normal mode.
For instance, press V to enter V-Line mode, select next word with w. press y to yank (copy), you are now automatically put back in normal mode as you have completed selecting your text.
Implemented Keystrokes (Vim Motions)#
The table below shows the vim motions currently implemented in novelWriter.
Motion |
Mode(s) |
Description |
|---|---|---|
i |
Normal → Insert |
Enter insert mode |
I |
Normal → Insert |
Jump to first non-blank of line and enter insert |
v |
Normal → Visual |
Enter character-wise visual mode |
V |
Normal → V-Line |
Enter line-wise visual mode |
dd |
Normal |
Delete (cut) current line |
x |
Normal |
Delete character under cursor |
w |
Normal / Visual |
Move to next word start |
b |
Normal / Visual |
Move to previous word start |
e |
Normal / Visual |
Move to next word end |
dw |
Normal |
Delete from cursor to next word start |
de |
Normal |
Delete from cursor to next word end |
db |
Normal |
Delete from cursor to previous word start |
d$ |
Normal |
Delete from cursor to end of line |
yw |
Normal |
Yank (copy) from cursor to next word start |
gg |
Normal / Visual |
Jump to first line |
G |
Normal / Visual |
Jump to last line |
yy |
Normal |
Yank current line |
p |
Normal |
Paste after current line |
P |
Normal |
Paste before current line |
o |
Normal → Insert |
Open new line below and enter insert |
O |
Normal → Insert |
Open new line above and enter insert |
$ |
Normal / Visual |
Move to end of line |
a |
Normal → Insert |
Enter insert after cursor |
A |
Normal → Insert |
Enter insert at end of line |
u |
Normal |
Undo last change |
zz |
Normal |
Centre cursor vertically |
h |
Normal / Visual |
Move left |
j |
Normal / Visual |
Move down |
k |
Normal / Visual |
Move up |
l |
Normal / Visual |
Move right |
d |
Visual / V-Line |
Delete selection |
x |
Visual / V-Line |
Delete selection |
y |
Visual / V-Line |
Yank selection |
0 |
Visual |
Move to start of line (extend selection) |
Known Issues#
Currently, dd on an empty line will not delete, but using x will.
vypyy will have ypyy in command memory and thus not register yy. Expected behavior would be visual mode, yank, paste, yank line.
Differing behavior from vim: the e command behaves a bit differently with regards to the last character of a word. The behavior is inconsistent with vim but functional and still logical to use. The cursor is placed at the end of the word after the last character rather than on the last character.
test ^ Cursor placed here in vim test ^ Cursor placed here in novelWriter vim mode
You will only really ever notice this behavior if you try to combine the e command with another. For instance, de will not delete the last character but delete forward as it starts one character after the word boundary.