Say I want to run the key combo <C-e> five times from a Vim script. Is that possible? If so, how is it done?
Specifically, I need this because I want to map a key to nudge the viewport one fourth of the screen height in a direction. For that I need to combine the function winheight(".") with the key combo <C-e> somehow.
Note: I know I can change the option 'scroll' to set the number of lines <C-u> and <C-d> scroll, but that key combo also moves the cursor. Additionally, I don’t know how to set the 'scroll' option to scroll a portion of the window height, except that it scrolls half the window height when I set it to 0.
For simple commands,
:norm[al][!]is sufficient. For example, to yank a line:For special characters, use
:exe[cute] "norm[al][!]". For example, to do5<C-e>:With
exe, other code can be inserted by using multiple arguments:However, arguments are joined with spaces, which are then interpreted literally. To avoid this, use
.to join arguments. Thus, for the desired effect:See
:help normand:help exefor more information.