justinmk / vim-sneak

The missing motion for Vim :athletic_shoe:
http://www.vim.org/scripts/script.php?script_id=4809
MIT License
3.26k stars 88 forks source link

"omap f <Plug>Sneak_f" does not include last char in buffer (using "co") #228

Open blueyed opened 6 years ago

blueyed commented 6 years ago

Given a minimal vimrc:

let &runtimepath .= ','.fnamemodify(expand('<sfile>'), ':h')
omap f <Plug>Sneak_f

cfl in a buffer that contains only one like "eval" will result in l being left (and not changed/removed). This appears to be related for when it is at the end of the buffer, i.e. a newline after it will remove the "l" as expected.

justinmk commented 6 years ago

I wonder if https://github.com/justinmk/vim-sneak/pull/181 fixes this.

blueyed commented 6 years ago

Nope..

ggandor commented 3 years ago

Yep, operators won't work properly if the target area extends to the very last column in the buffer, because we cannot "nudge" the cursor beyond the last column (to compensate the default "exclusive" interpretation of the motion). There are two solutions: 1. We can just tell the user to use the 'v' modifier, forcing inclusiveness (:h o_v) 2. We could set virtualedit temporarily to onemore, move the cursor beyond the last column, and then revert virtualedit with an autocommand after the function has finished. Do we need to bother with this edge case?

justinmk commented 3 years ago

We could set virtualedit temporarily to onemore, move the cursor beyond the last column, and then revert virtualedit with an autocommand after the function has finished.

good idea! not ideal because it changes the :verbose set virtualedit? history, but we could be smart about it and only do this hack when this edge case is detected.