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.

lizhe
  • 137
  • 6

1 Answers1

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.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271