Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape a double-quote in .vimrc

Tags:

vim

I'd want to add this mapping:

map <C-K> "_dd

How do I escape that double quote so it won't be interpreted as a comment?

like image 853
Gavin Avatar asked Jan 21 '23 14:01

Gavin


2 Answers

I think you’ll be fine.

From the manual:

                                                        *:quote*
'"' at the start of a line causes the whole line to be ignored.  '"'
after a command causes the rest of the line to be ignored.  This can be used
to add comments.  Example: >
        :set ai         "set 'autoindent' option
It is not possible to add a comment to a shell command ":!cmd" or to the
":map" command and friends, because they see the '"' as part of their
argument.

Notice how it says after a command — unfortunately, it can be difficult to tell what exactly is meant by the end of the command. Some commands (:edit) take only one argument, while others (:map, :help), can consume everything on the line.

In other words, using " after a :map should work fine without any special treatment, and I would stick to that as a guideline. If you find that it treats the " as the beginning of a comment, just use a backslash: \".

like image 90
Josh Lee Avatar answered Jan 24 '23 04:01

Josh Lee


Just a guess. The issue is probably not with the mapping of a double-quote but the fact that <C-K> is noremapped somewhere else. Run the command :map and see if <C-K> is mapped elsewhere? If it cannot be remapped it will have an asterix.

I know minibufexplor.vim uses <C-K> so that could be your problem?

Hope this helps.

like image 30
Joe Axon Avatar answered Jan 24 '23 04:01

Joe Axon