2

I'd like to write commands that work with :tab and :vert. Say I have a command that opens a new split window as shown below

function! FooSplit()
    let l:message="hello world"
    new
    put! =l:message
endfunction
command! -complete=command Foo call FooSplit()

I'd like it to make it so that :tab Foo and :vert Foo will open in a new tab and vertical split respectively.

4

You can use :h <mods> to do this, it expands to modifier or nothing. It's added at patch 7.4.1898

command Foo call FooSplit(<q-mods>)

function FooSplit(mods)
  exe a:mods 'new'
endfunction

Above example use <q-mods> instead of <mods>, as you need it as a string.

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.