One can create non-rectangular Visual-Block selections using
C-v$ on files with lines of non-equal length.
Is it possible to programmatically determine whether the last Visual Block selection was non-rectangular?
A little crude but this works...
func! IsDollarBlock() let l:mode = char2nr(visualmode("")) if l:mode != 22 echom char2nr(l:mode) . " is not block mode" return 0 endif sil norm! gv"aygv$"by return @a == @b endfunc
You can test with...
(Assuming visual selection was not active)...first this checks whether the last visual selection was even block mode. If not it returns 0 (false). Otherwise it re-selects the visual selection and yanks into register "a", re-selects it again, issues
$ and yanks into register "b". Then it compares the two registers and returns the comparison result (0/false or 1/true).
If you wanted to preserve the visual selection you could issue
<Esc> or equivalent at the beginning of the function then put
norm! gv as last command of the function.