In studying VIM functions to learn to write my own I see that commands are sometimes written preceded with the keyword normal:
normal mz
Sometimes with the normal wrapped in an exec:
exec "normal mk"
Or sometimes alone on the line;
0d
Where in the fine manual is this addressed?
You’re getting confused with the various modes. More specifically, the command
mode and normal mode.
Command mode is where the ex commands are applied, the commands that begin
with a colon. VimScript files are just a sequence of ex commands.
When you need to perform a normal mode command while in ex mode (command mode)
you use the
:normalex command, which executes the arguments as they wouldbe in normal mode.
When you execute command directly, well, you’re executing it directly. In your
example, the
:dcommand was used with a range. That’s not the same as thedkey in normal mode, that’s another entirely different command. Check thehelp for
:dandd(the normal command).The
:executeis useful to build a command as a string and execute it as anex command. In your example, it’s useless. But it becomes handy in other
cases, as an example when you have a variable holding a line number and wants
to use its value in a command:
Which is just the same as