You can use the following code:
function! CombinedTabularize() range
execute a:firstline . ',' . a:lastline . 'Tabularize /\/\/'
execute a:firstline . ',' . a:lastline . 'Tabularize /;'
command! -range CT <line1>,<line2>call CombinedTabularize()
CombinedTabularize() takes a range thanks to the
range option. When using this option the lines in the range are available with
CT also takes a range and pass the selected lines to the function with
execute commands are used to concatenate the lines of the range and the
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: