Tuesday, January 5, 2016

Re: vim function not

Hi JomarBueyes!

On Di, 05 Jan 2016, JomarBueyes wrote:

> Hi,
>
> I'm having this problem: I define a function as
>
> function SetTabs(w)
> set sw=a:w
> set tabstop=w
> ( some other settings )
> endfunction

:set does not accept expressions and does not expect variables. It wants
option values. The usual way to do this is either use exe to substitute
the variables:

:exe "set sw=".a:w

or even better in this case use the :let statement and access the option
values as &option like this:
:let &sw=a:w

See :h expr-option



Best,
Christian
--
Polizisten sind wie Schnittlauch: innen hohl, Augen grün, und sie treten
meistens in Bündeln auf.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: