1

I want to run a command when I change the textwidth. I have tried autocmd CmdlineLeave * call Myfunction()

When I do :set tw=40, the function is called before tw is changed.

What is the best way to do this ?

5

There's OptionSet autocommand. For example,

augroup test | au!
    autocmd OptionSet textwidth call NewTextWidth(v:option_type, v:option_new)
augroup end

function! NewTextWidth(type, value)
    echom 'set' a:type 'textwidth' a:value
endfunction
| improve this answer | |
  • Thanks, this is exactly what I need – Ôrel Apr 14 at 23:42

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.