One strange thing about vimscript is that it automatically converts string to numbers when some
operations are applied.
For example, if you try this:
You will get 'hi' as the output, but if you try this:
You will get nothing.
This happens because the condition of an 'if' sentence has to be an int, so both strings are
automatically converted likewise and we get 123 and 0 respectively because the conversion stops
at any non digit char.
The value stored in colorcolumn option is a string as stated in the help (see 'colorcolumn'),
specifically a comma separate list of values with the type string that contain the column
numbers that are highlighted.
Just like 'if' sentence, the minus sign '-' requires numbers to be its operands and strings will
be converted (until first non digit) in order to accomplish that.
So when you do:
&cc - virtcol('$')
The value of &cc which is originally "80,132" automatically converts to 80
losing the 132 and any other value.
If you want to treat all the separated values, I would recommend you to split the contents of
colorcolumn with the split() function:
let value_list = split(&cc, ',') " Split values at ,
Then, you can use a for statement to treat all the values. You can also query the length by
using the len() function:
for value in value_list
echo 'The value is: ' . value
let number_of_values = len(value_list)
for i in range(number_of_values)
echo 'The value in ' . i . ' position is: ' . value_list[i]