Chris Lott, Fri 2012-01-13 @ 12:39:22-0900:
> One can remap hjkl to go line by line visually, which is what I do as
> I write primarily prose and for various reasons choose to use one line
> per paragraph.

I have the following in my .vimrc, which lets me toggle between "screen
line" and "buffer line" movement by pressing <F7>:

    function! ToggleScreenLineMovementMode()
        if !exists("g:screen_line_movement_mode")
            let g:screen_line_movement_mode = 0
        endif
        if !g:screen_line_movement_mode
            echomsg 'Moving by screen lines'
            let g:screen_line_movement_mode = 1
            nnoremap j gj
            nnoremap k gk
            nnoremap $ g$
            nnoremap 0 g0
            nnoremap ^ g^
        else
            echomsg 'Moving by buffer lines'
            let g:screen_line_movement_mode = 0
            nunmap j
            nunmap k
            nunmap $
            nunmap 0
            nunmap ^
        endif
    endfunction
    nnoremap <silent> <F7> :call ToggleScreenLineMovementMode()<CR>

The only caveat is that it will clobber any pre-existing mappings you
have for j, k, $, 0, and ^. I don't have any, so it's no problem for me,
but that may not be the case for everyone.

Attachment: pgpq2qbpQBlty.pgp
Description: PGP signature

Reply via email to