问题
What’s the difference between single ('
) and double ("
) quotes in Vim? Does it make speed differences? Is it better to use one or another when running functions inside it? Does it matter at all?
I’m interested specifically in their use in the .vimrc
file.
I’m asking because I find people use both in the same thing, and I’m wondering what are the differences. I tried to Google this, but wasn’t able to find anything.
回答1:
Double quotes allow for interpolation whereas single quotes do not.
For example, using double quotes :echo "foo\nbar"
will output foo
and bar
on separate lines whereas :echo 'foo\nbar'
will not interpret \n
as a line break and will output foo\nbar
literally.
For more info on different types of quotes type :h 41.2
for the help file and read the part near the end of the section with the heading STRING VARIABLES AND CONSTANTS
.
This said, don't confuse quotes for strings with the double quote at the beginning of a line comment. Single quotes never start line comments, only double quotes do.
来源:https://stackoverflow.com/questions/13435586/should-i-use-single-or-double-quotes-in-my-vimrc-file