Saturday, August 20, 2011

Tweaking $ command

Hi, I was trying to change $ command to go to N chars before the end of
line, and found it surprisingly hard to do. Here's what I come up with:

func! EndOfLine()
exe "normal \<End>"
let c = v:count
let c2 = c - 1
let cmd = "normal " . c2 . "k" . c . "h"
if c | exe cmd | endif
endfu
nnoremap $ :<c-u>call EndOfLine()<cr>


Is there a better way to do this? Why is <c-u> needed there? If I
remapped $, why does it keep trying to do built-in $ handling of count?
Why can't I do 'normal $' in the function despite using nnoremap?

Thanks, -ak

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: