2

When I read the comment help file, I found

It is not possible to add a comment to a shell command ":!cmd" or to the ":map" command and a few others (mainly commands that expect expressions) that see the '"' as part of their argument: ...

What is it mean?

I add the line ":!ls" to my vimrc file and nothing changes.

1 Answer 1

3

What it means you can't start a comment after the command; with ":!ls" the " is before the command and comments out the entire line, and that's okay, but something like this won't work:

:!ls /  " List root directory

Because the " is interpreted as part of the shell command. It's the same with the :map commands; for example to create a map to add a quote at the end of the line we could do:

:nnoremap Q $a"<Esc>

But how will Vim know that " is what you intended to be part of the map or a comment? Vim solves this by just not interpreting comments for a few special commands.

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.