Vim: Call an ex command (set) from function?

Posted by sixtyfootersdude on Stack Overflow See other posts from Stack Overflow or by sixtyfootersdude
Published on 2010-03-29T19:03:35Z Indexed on 2010/03/29 19:13 UTC
Read the original article Hit count: 373

Filed under:
|
|
|

Drawing a blank on this, and google was not helpful.

Want to make a function like this:

function JakPaste()
        let tmp = :set paste?
        if tmp == "paste"
                set nopaste
        else
                set paste
        endif
endfunction

map <F2> :call JakPaste()<CR>

However this does not work. I have isolated the broken line:

function JakPaste()
        let tmp = set paste?
endfunction

map <F2> :call JakPaste()<CR>

Pressing F2 results in this error:

Error detected while processing function JakPaste:
line    1:
E121: Undefined variable: set
E15: Invalid expression:  set paste?
Hit ENTER or type command to continue

How should I call an ex command (set) from a vim function?

This seems somewhat relevant however I still don't get it.

© Stack Overflow or respective owner

Related posts about vim

Related posts about function