Vim logo vim online Vim Book Ad

basic Tip #400: Fast scroll mappings (incl. insert mode)

 tip karma   Rating -1/1, Viewed by 314 

created:   January 13, 2003 10:58      complexity:   basic
author:   John Sumsion      as of Vim:   6.0

" allow Alt-[movement keys] to scroll window
if !has("gui_running")
    nmap ^[l <A-l>
    nmap ^[h <A-h>
    nmap ^[k <A-k>
    nmap ^[j <A-j>
    vmap ^[l <A-l>
    vmap ^[h <A-h>
    vmap ^[k <A-k>
    vmap ^[j <A-j>
    imap ^[l <A-l>
    imap ^[h <A-h>
    imap ^[k <A-k>
    imap ^[j <A-j>
endif

" To have <A-h> available for the mappings below, search menu.vim for the
" first instance of &Help; and change it to Hel&p; so that <Alt-H> isn't used
" for the GUI Help menu
nmap <A-l> 4zl
nmap <A-h> 4zh
nmap <A-k> <C-y>
nmap <A-j> <C-e>
vmap <A-l> 4zl
vmap <A-h> 4zh
vmap <A-k> <C-y>
vmap <A-j> <C-e>
imap <A-l> <C-o>4zl
imap <A-h> <C-o>4zh
imap <A-k> <C-x><C-y>
imap <A-j> <C-x><C-e>

 rate this tip  Life Changing Helpful Unfulfilling 

<<fold away empty lines | A mapping for easy switching between buffers >>

Additional Notes

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo