Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch19 Poor example for why we should use let instead of set #24

Open
sedm0784 opened this issue Apr 16, 2012 · 2 comments
Open

Ch19 Poor example for why we should use let instead of set #24

sedm0784 opened this issue Apr 16, 2012 · 2 comments

Comments

@sedm0784
Copy link

Chapter 19:

Why would we want to do this when we could just use set? Run the following
commands:

:let &textwidth = &textwidth + 10
:set textwidth?

This time Vim displays "textwidth=110". When you set an option using set you
can only set it to a single literal value.

But in this case we can also do exactly the same thing with set:

:set textwidth=100
:set textwidth+=10
:set textwidth?

Vim displays "textwidth=110".

@sjl
Copy link
Owner

sjl commented Oct 12, 2012

Yeah, it's tough to come up with simple examples that don't require a lot of outside knowledge. If you can think of a good standalone example here let me know.

@filbranden
Copy link

One possible example would be a command to increase textwidth by 15% or something similar.

:let &textwidth = &textwidth * 115 / 100

That couldn't really be accomplished using :set (well there's ^= but that doesn't seem to work with a float.) Just a suggestion... Thanks for the excellent guide!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants