Closed kbdnr closed 9 years ago
Hey @kbdnr, thanks for the PR! I don't understand what it fixes though... does Vim throws an error when calling getcurpos()
? From the docs, I can see getpos('.')
is the same, except that it doesn't store the prefered column:
getcurpos() Get the position of the cursor. This is like getpos('.'), but
includes an extra item in the list:
[bufnum, lnum, col, off, curswant]
The "curswant" number is the preferred column when moving the
cursor vertically.
This can be used to save and restore the cursor position:
let save_cursor = getcurpos()
MoveTheCursorAround
call setpos('.', save_cursor)
Yes for me vim is throwing an error.
I can elaborate and provide a screenshot if you would like to see the previous errors i had encountered. Additionally, i don't see the purpose of the unnecessary overhead involved in the previous implementation where regardless, the blocks are selected by essentially inspecting the surrounding (or lack of) whitespace. Great implementation otherwise
I can elaborate and provide a screenshot if you would like to see the previous errors i had encountered.
Yes, that'd be great!
Additionally, i don't see the purpose of the unnecessary overhead involved in the previous implementation where regardless, the blocks are selected by essentially inspecting the surrounding (or lack of) whitespace. Great implementation
Do you mean storing/restoring the cursor position? Or just using getcurpos()
?
If it's the former, I'd say a disagree, as I think it's really useful to keep the cursor in the same place after executing. It allows you to, for example, play and try different values of a parameter or something in the middle of a line very quickly.
If you meant the use of that function, getpos('.')
is still a good alternative, although I'd like to know first if the error you're having can be fixed.
https://i.imgur.com/9tT5Imu.png
additionally with my fix you do not lose the cursor position, so I disagree with your logic on that.
Apparently, getcurpos
was added on version 7.4.313 (!)
I'll merge this and try to add a check and use getcurpos
only if it's available.
Thanks!
Fix to method call for multi-line getpos execution.