What is the NOP code for vimscript?


3 Answers 3


VimScript interpreter ignores colons and spaces, so : could be qualified as "nop" command. For example, echo 'foo' | : is the same as just echo 'foo'.

However, there's a problem: due to Vi compatibility :| is forcefully parsed as :print, so echo 'foo' | : | echo 'bar' surprisingly transforms into echo 'foo' | print | echo 'bar'.

To deal with this one can create a user-defined command, e.g.

command! -bar Nop :

Now this works: echo 'foo' | Nop | echo 'bar'


The command execute with no arguments is a no-op. Importantly, :echo 'bar' | execute | echo 'foo' does not transform to contain a print.


According to the url provided:

The simplest possible statement in C that behaves like a NOP is the so-called null statement, which is just a semi-colon in a context requiring a statement. (A compiler is not required to generate a NOP instruction in this case; typically, no instructions whatsoever would be generated.)


Alternatively, an empty block (compound statement) may be used, and may be more legible:


What about "empty command" :

func! Test()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.