Blog: 2026-03-17

From razwiki
Revision as of 03:52, 17 March 2026 by Razzi (talk | contribs) (Created page with "Ok getting the column for vim in insert mode is actually a mess. After https://superuser.com/questions/723621/how-can-i-check-if-the-cursor-is-at-the-end-of-a-line I figured I'd be good handling the empty column case ... but it actually treats the cursor being on the last character and the second-to-last character the same?? inoremap <C-f> <C-o>:call JustTellMeColumn()<cr> function! JustTellMeColumn() echom "COL is " . col(".") . " and EOL: " . AtEndOfLine()...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Ok getting the column for vim in insert mode is actually a mess.

After https://superuser.com/questions/723621/how-can-i-check-if-the-cursor-is-at-the-end-of-a-line

I figured I'd be good handling the empty column case ...

but it actually treats the cursor being on the last character and the second-to-last character the same??

inoremap <C-f> <C-o>:call JustTellMeColumn()<cr>
function! JustTellMeColumn()
  echom "COL is " . col(".") . " and EOL: " . AtEndOfLine()
  messages
endfunction

And sure enough

ecoh"|
ecoh|"

Both give column = 5!!! like whaaaa how am I supposed to determine if the cursor is on a special character like this?

Or at end of line? Should never be both right?

I think I need to find another way to get the cursor position. The line,col at the bottom seems accurate, maybe get that...

Ok incredible, if I set

set virtualedit=onemore

then I can actually get the "final" column ... and col("$") returns the same number.

Ok done... wow what a journey