Blog: 2026-03-17: Difference between revisions

From razwiki
Jump to navigation Jump to search
(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()...")
 
No edit summary
 
Line 33: Line 33:


Ok done... wow what a journey
Ok done... wow what a journey

Could add my answer to this stackoverflow q: https://superuser.com/questions/723621/how-can-i-check-if-the-cursor-is-at-the-end-of-a-line

Latest revision as of 03:53, 17 March 2026

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

Could add my answer to this stackoverflow q: https://superuser.com/questions/723621/how-can-i-check-if-the-cursor-is-at-the-end-of-a-line