I am trying to create something like "new mode" in vim. The details of the mode are unimportant, but there is one thing I need to do.
I need to do something like the following pseudocode:
get user input (movement keys like "j" or complex keys like "dd") while user_input != <esc> execute the user input endwhile
In other words, I need a loop that will read what the user is doing and then perform a related action.
I already have the following code:
let char = nr2char(getchar()) while char =~ '^\w$' execute "normal ". char let char = nr2char(getchar()) endwhile
This is great for custom motions ( j , k , etc.), but not for more complex multi-character commands like dd .
Also, this is a little annoying, but the cursor disappears during getchar (), which means you cannot see the cursor (this is less important due to what I'm trying to do, but hopefully has a solution as well).
Does anyone know how I can make multi-character actions work?
source share