Re: saving and setting option
- On Wed, Mar 10, 2010 at 7:07 AM, Jürgen Krämer <jottkaerr@...> wrote:
>Or, more safely:
> J.Hofmann@... wrote:
>> I d like to do the following:
>> - remember the current value of an option, i.e. 'enc' , into a variable by
>> one vim script
>> - Doing some stuff, which changes the option
>> - re-set the option with the remembered value by another vim script.
>> What would be the syntax for this remembering and setting?
> you can access options as "variables" by prefixing them with an ampersand,
> let old_enc = &enc
> " do some stuff
> let &enc = old_enc
let old_lz = &lazyredraw
" do some stuff
let &lz = old_lz
This method guarantees that the setting gets restored, even if the
code in between exits abnormally through an exception or some such.
Also, please note that it's not a good idea to change 'enc' once vim
has started. See the note right above :help 45.4 among other places
in the help for explanations about why. Historically, changing 'enc'
in a running vim has been able to trigger crashes, and even now it's
very likely to break plugins, etc
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php