Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call an editor command from a vimscript?

Tags:

vim

I want to remove an unwanted scrollbar from taglist. I created a function and a command like this:

function s:TlistWaToggle()
    normal :TlistToggle<cr> " <- this does not work
    set guioptions-=r
endfunction

command! -nargs=0 -bar TlistWaToggle call s:TlistWaToggle()

I want to wrap the call to :TlistToggle together with the command to remove the right scrollbar (I have that setting of course, but it always reappears, so this is a workaround). Currently my :TlistWaToggle doesn't do anything. How can I make it work?

like image 945
Tamás Szelei Avatar asked Oct 02 '11 14:10

Tamás Szelei


People also ask

How to execute a Vimscript file?

You can always execute Vimscript by running each command in command mode (the one you prefix with : ), or by executing the file with commands using a :source command. Historically, Vim scripts have a . vim extension. Here, :so is a short version of :source , and % refers to the currently open file.

What is call in Vim?

:call is for calling functions, e.g.: function! s:foo(id) execute 'buffer' a:id endfunction let target_id = 1 call foo(target_id) :execute is used for two things: Construct a string and evaluate it. This is often used to pass arguments to commands: execute 'source' fnameescape('l:path')

What is VimL?

Vim script (also called Vimscript or VimL) is the scripting language built into Vim. Based on the ex editor language of the original vi editor, early versions of Vim added commands for control flow and function definitions.


1 Answers

Vim script uses ex commands, and apparently :TlistToggle is an ex command…

function! s:TlistWaToggle()
    TlistToggle
    set guioptions-=r
endfunction
like image 55
sidyll Avatar answered Oct 31 '22 17:10

sidyll