Should I use single or double quotes in my .vimrc file?

江枫思渺然 提交于 2019-12-03 16:06:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!