1

In Vim9 script :let cannot be used. An existing variable is assigned to without any command. The same for global, window, tab, buffer and Vim variables, because they are not really declared. Those can also be deleted with :unlet.

https://vimhelp.org/vim9.txt.html

The quotation above is not really clear to me. Here is a part of my .vimrc, how can I unlet skip_defaults_vim?

unlet! skip_defaults_vim
    # Load defaults.vim even if system-wide .vimrc has been found
source $VIMRUNTIME/defaults.vim

1 Answer 1

5
  1. Global variables are still the same as in legacy script, so unlet works as before. The only difference is that the prefix g: now is always required to access global variables.
  2. Unletting non-existent variable is pretty much like talking to invisible friend.
  3. Translating vimrc into Vim9 script / Lua / whatever is a waste of time.
6
  • > Unletting non-existent variable is pretty much like talking to invisible friend. Why you gotta say it like that. > Translating vimrc into Vim9 script / Lua / whatever is a waste of time. Quite literally. Because you have already done the work. Why would you ever wanna do something you've already done?
    – kadekai
    Jul 30 at 18:37
  • Matt, but why unlet! skip_defaults_vim gives me an error?
    – user90726
    Jul 31 at 5:08
  • 2
    @user90726 Because you can't unlet local variable (this is compiled language, remember?). In VimScript it defaults to global, in Vim9 script it defaults to local.
    – Matt
    Jul 31 at 5:11
  • Sorry for a late comment (I was in a hospital these days, after a kind of "street fight" with two idiots), but then another question: what I need to do in such a case? Because it is now local and therefore I cannot unlet it, what is the new way to load defaults.vim even if system-wide .vimrc has been found? Well, this might be better to open a separate question to ask this.
    – user90726
    Aug 5 at 15:57
  • 1
    @user90726 1) You don't need to unlet it, as it does not exist (unless you created it earlier and I guess it is not the case); 2) If you really need to unlet global variable then you must mark it is global one, i.e. use g: prefix. In legacy script it was optional, now it is required.
    – Matt
    Aug 5 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.