plugin Vim Mode (CudaText)

Plugins for SynWrite and CudaText...
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

plugin Vim Mode (CudaText)

Post by Alexey »

plugin for CudaText.
command in Plugins menu activates Vim key bindings, initially in Vim command mode. Vim mode is activated in all editor tabs at once. indication of Vim mode is full-block-framed caret.

a) Vim insertion mode - all keys work like usual in CudaText, only Esc goes to command mode
b) Vim replace mode - like insertion mode, but "insert/overwrite mode" is "overwrite"
c) Vim visual mode - all movement keys (arrows/home/end/pageup/pagedown) make selection w/o Shift
d) Vim command mode supported keys:
h, j, k, l - move caret (4 arrows)

w - go to next word (jumps not exactly like Vim, but like CudaText command "go to next word")
b - go to previous word (same note)
e - go to end of word (or next word)

a - enter insertion mode, after moving caret right
A - enter insertion mode, at line end
i - enter insertion mode, at current pos
I - enter insertion mode, at first non-space char in line

r - replace current char with next typed char, return to command mode
R - enter replace mode

o - creates empty line below, goes into insertion mode on new line
O - creates empty line above, goes into insertion mode on new line

gg - go to text begin
G - go to line number (if number entered before), or go to text end (if none)

| - go to column number (if number entered before, else column 1)
0 - go to line begin (column 1)
^ - go to first non-whitespace
- - go to first non-whitespace, in previous line
+ - go to first non-whitespace, in next line
$ - go to line end

X - delete char left (like Backspace key)
x - cut selection (if selection) or one char
y - yank (copy) to clipboard
p - paste from clipboard, after caret
P - paste from clipboard, before caret

D - delete to end of line
dd - delete current line
db - delete to word begin
dw, de - delete to word end (currently commands work the same)
dL - delete to text end
d/ - delete until text position (text is asked in dialog)

C - change to end of line (delete to end of line, go to insertion mode)
c - change - like "d" commands (cd, cb, cw, ce...) but also goes to insertion mode

v - enter visual mode
V - enter visual mode, but select entire lines

Space - move right
Backspace - move left

/ - search forward, prompts for string in dialog
? - search backward
n - repeat search in the same direction
N - repeat search in the opposite direction
f - find next typed character, inside line
F - backward version of "f"
t - like "f" but set position minus one char
T - backward version of "t"

u - undo
~ - invert case of selection (if selection) or one char
J - join current line with the next one (delete EOL at current line)
oO0XX0Oo
Posts: 18
Joined: 19.11.2018 21:51

Post by oO0XX0Oo »

Thanks for supporting vim commands in CudaText!

May I ask for three improvements?

01. Support the optional [count] for all commands that support this
Examples (in command mode):

Code: Select all

4V -> Switch to select full line mode and select 4 lines
4dd -> Delete 4 lines
3w -> Jump to the 3rd word
etc.

02. Remember the last used action in command mode and allow us to repeat it via:

Code: Select all

..
E.g.:

Code: Select all

dd
..
-> Repeats the last command, in this case, repeat the line deletion

03. The different caret modes are a way to show in what mode we're currently are
It would be a lot more recognizable if you could (as an option) colorize the status
bar instead. Like the Vim (vscodevim) plugin does it in Visual Studio Code.
E.g. the insert modes colorizes the status bar red, visual mode purple and command prompt uses teal
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Sure, I want to work on it, soon will try.
oO0XX0Oo
Posts: 18
Joined: 19.11.2018 21:51

Post by oO0XX0Oo »

Ok, thanks for the feedback!
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Task-3 is done, statusbar indicator. Plugin is updated.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Task-2:
what docs show about .. ? This dont have info - https://www.fprintf.net/vimCheatSheet.html
I want it to be like in vim.
oO0XX0Oo
Posts: 18
Joined: 19.11.2018 21:51

Post by oO0XX0Oo »

It's a single dot, not two. Sorry, just saw it, that I've showed double dots.

On the site you've mentioned it's under:
Undo/Redo/Repeat
. Repeat last change, with count replaced with [count].

Thanks for the colorization option!
There isn't any chance to colorize the whole status bar, right?
Or if this isn't possible, to move the status indicator from the rightmost
position to the leftmost one (as an option)?
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Rightmost position is better: it dont shift first cells to th right. Why colorize the whole bar, it is not nice.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

seems, "repeat last text command" is not ok: command "r2" (replace char to /2/) not repeated.
oO0XX0Oo
Posts: 18
Joined: 19.11.2018 21:51

Post by oO0XX0Oo »

Why colorize the whole bar, it is not nice.
I find it extremely nice. I have an ultrawide monitor (a Dell with 3840 x 1600 resolution)
and looking into the lower right corner just to see the status is cumbersome (I'm not
from a country where RTL language is used <)). The way VS Code does it is ideal for
it's purpose. You always know in which mode you are because the color is prominent
enough regardless where you look...
insert_mode.png
Maybe you could add an option that allows us to colorize the full bar (while the default
is still only the segment in the lower right)?
"." command - it must be the same as Cudatext's command "repeat last text command", ok?
I don't know if this has any implications. As long as it works I'd be happy :mrgreen:
Post Reply