2

Have the following simple function in a vim script:

function me#Tabwidth(width)
    let &tabstop = a:width
    let &shiftwidth = a:width
    set expandtab
    echom "Tab width set to " + a:width
endfunction

The function is being called like this in the vimrc file.

command -nargs=* Tabwidth :call me#Tabwidth(<f-args>)

When called by typing "Tabwidth 2" only the value of the variable is being echoed out, but not the string. What am I doing wrong?

1 Answer 1

3

In vim script, string concatenation is done with . operator. Try like this:

echom "Tab width set to " . a:width

If a:width is a number, it will be automatically converted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.