I have the following command for \ that jumps to the last character unless the cursor is under the last character, in which case it jumps to the start of the line.
nnoremap <silent> <expr> \ ((col(".") >= col("$")-1) ? "^" : "$")
It works great most of the time unless the final character is a multibyte char, e.g. the 1-line file multibyte.txt (given below)
aaaaaaaaaa的的的的的的的
\ moves to the end of the line, but repeatedly pressing it keeps it there.
Is it possible to detect whether the cursor is at the last byte in a line, regardless of the number of bytes that make up the character?