Vim: let 和 set 有什么区别? [英] Vim: What's the difference between let and set?

查看:45
本文介绍了Vim: let 和 set 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vim 编辑器中的 letset 有什么区别?

What's the difference between let and set in the vim editor?

我一直想知道为什么它们都存在?

I've always wondered why both of them exist?

另外,我很想知道它的历史背景.

Also, I'd be interested to hear its historical background.

推荐答案

:set 用于设置options:let 用于分配一个变量的值.

:set is for setting options, :let for assigning a value to a variable.

碰巧一个选项的值链接到由 & 前缀的选项名称(&option-name 结构然后表现得非常相似到普通"变量).因此,以下内容是等效的:

It happens that the value for an option is linked to the name of the option prepended by a & (the &option-name construct then behaves very similar to "ordinary" variables). So, the following are equivalent:

:set  tw=40
:let &tw=40

但是,例如,将 50 分配给全局变量 foo (:let g:foo=50) 无法通过 :set 命令实现(因为 g:foo 是一个变量而不是一个选项).

But, for example, assigning 50 to the global variable foo (:let g:foo=50) cannot be achieved with a :set command (because g:foo is a variable and not an option).

有些选项类似于布尔值.设置这些时,不需要任何值(如 :set noic 和相反的 :set ic).

Some options are boolean like. When setting these, no value is needed (as in :set noic and the opposite :set ic).

这篇关于Vim: let 和 set 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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