我应该在.vimrc文件中使用单引号还是双引号? [英] Should I use single or double quotes in my .vimrc file?

查看:288
本文介绍了我应该在.vimrc文件中使用单引号还是双引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vim中单引号(')和双引号(")有什么区别?它会造成速度差异吗?在其中运行函数时使用一个或另一个更好吗?没关系吗?

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?

我对它们在.vimrc文件中的使用特别感兴趣.

I’m interested specifically in their use in the .vimrc file.

我之所以问是因为我发现人们在同一件事中同时使用两者,我想知道有什么区别.我尝试使用Google进行搜索,但找不到任何内容.

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.

推荐答案

双引号允许插值,而单引号不允许.

Double quotes allow for interpolation whereas single quotes do not.

例如,使用双引号:echo "foo\nbar"将在单独的行上输出foobar,而:echo 'foo\nbar'不会将\n解释为换行符,并且将按字面输出foo\nbar.

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.

有关不同类型引号的更多信息,请在帮助文件中键入:h 41.2,并阅读标题为STRING VARIABLES AND CONSTANTS的该节末尾附近的部分.

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.

这篇关于我应该在.vimrc文件中使用单引号还是双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆