You can use the following code:
function! CombinedTabularize() range
execute a:firstline . ',' . a:lastline . 'Tabularize /\/\/'
execute a:firstline . ',' . a:lastline . 'Tabularize /;'
endfunction
command! -range CT <line1>,<line2>call CombinedTabularize()
The function CombinedTabularize()
takes a range thanks to the range
option. When using this option the lines in the range are available with a:firstline
and a:lastline
.
The command CT
also takes a range and pass the selected lines to the function with <line1>
and <line2>
.
The execute
commands are used to concatenate the lines of the range and the Tabularize
calls.
About the code you tried to use here are the different problems:
- Your command uses the
range
option but doesn't pass the lines to the function.
- Your function doesn't use the range neither
- Your function execute
normal :cabbrev
which creates a new command line abbreviation but doesn't execute it
You might be interested in the following help topics:
:h func-range
:h command-range