I'm looking for a way to precisely set the cursor position given a virtual column.
Is there only :exe "normal! ".vcol."|"
?
NB: I need virtual columns as they're the only thing that I'm able to compute correctly in a context where there are multi-byte characters that occupy only one column, and tab characters that spawns over several columns.
Regarding the context, I should be more explicit. If I'm looking for a function, it's partly out of curiosity, partly to avoid translating a tuple of coordinates (that I already have thanks to getpos(a_mark)
) into something else, partly for style consistency: I'm trying to fix/enhance a plugin where I try to use functions. This implies I cannot expect something as the virtual editing mode to be in a state or in another: plugins need to work whatever the end-user choose for her/his vim options. Yet, it's true I could change it momentarily and restore it in a finally
statement.
Also, I'm not in the general case where I may end up in the middle of a tabulation. Any position, I want to jump to, is accessible without 'virtualedit'
being set. The (computed) position matches a placeholder in an expanded and re-indented code snippet.
:h setpos()
and use theoff
entry of the list taken as parameter?"off"
relates to virtualedit mode, which is not my situation.virtualedit
was mandatory to use virtual columns, my bad :)\t/*«»*/ if () {
,getcursorpos()
returns[0, 2, 14, 0, 19]
when the cursor is on the(
. The byte index is 14, but the actual (virtual...) column is 19 -- with&ts==8
virtualedit
momentarily. I've to think about that.