end-of-visual-line go to beginning of next line in Emacs -


i want use beginneing-of-visual-line , end-of-visual-line.

so wrote in .emacs following.

(global-set-key "\c-a" 'beginning-of-visual-line) (global-set-key "\c-e" 'end-of-visual-line) 

beginning-of-visual-line works hoped. if use c-e in visually multiple lines, cursor go beginning of next line.

why happens? , how can fix it?

i'm using emacs 24.3 (9.0) in mac os x 10.7.5.

i think in general, end-of-line position point on next character after end of line.

i find helpful when coding in lisp, because places point in perfect place evaluate previous s-exp easily.

however, in case of end-of-visual line, first character after end of line on next visual line. if want point on last character of current visual line, go 1 character, this:

(global-set-key (kbd "c-e") '(lambda ()                                (interactive)                                (end-of-visual-line)                                (backward-char))) 

edit

a better way of achieving same thing - fix point in comment, enable visual-line-mode:

(global-visual-line-mode 1) 

this automatically make c-a , c-e work visual lines.

the problem visual-line mode default, there no indicators showing line wrapped. fix this, can use:

(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow)) 

you'll need put visual-line-fringe-indicators assignment before global-visual-line-mode call in .emacs work.

source above: http://www.emacswiki.org/emacs/visuallinemode


Comments