Vim logo vim online Vim Book Ad

basic Tip #327: key mappings

 tip karma   Rating 2/11, Viewed by 1620 

created:   September 13, 2002 17:57      complexity:   basic
author:   Nithin      as of Vim:   6.0

I use my left thumb for the alt key and right for the space. Using this combo, you can get
some useful key maps for which you don't have to move your hands. I find I have to turn
my hand a little to press the left ctrl key.

These are some maps i use for C programming.

map ' `
map <C-f> :w<C-m>:!make<C-m>
map <M-]> <C-]>                                         Tags
map <M-[> <C-t>                                          Tags
map <M-u> :!ctags -R *<C-m>                                          Build Tags
map <M-c> I/*<Esc>A*/<Esc>                                          Comment current line
map <M-d> ^xx$xx                                          Delete comment for a single line
map <M-l> [{zf%                                          Fold upto the enclosing brace level
map <M-o> zo                                           open fold
map <M-i> zc                                          close fold
map <M-.> :cn<C-m>                                          Go to next error in list
map <M-,> :cp<C-m>                                          previous error in list

imap <Tab> <C-p>                                                  Complete word
inoremap <S-Tab> <Tab>                                                  Tab
inoremap { <CR>{<CR>                                                  Brace and line
inoremap } <CR>}                                                  brace and line. saves one enter stroke



imap <M-j> <Esc>                                                  Escape. Don't want to move my hand to esc key.
imap <M-k> <C-y>                                                  Copy line from above.
imap <M-q> /*  */<Esc>hhi                                        Comment selected lines

noremap <M-r> ddko{<C-m>}<Esc>kpko             Convert a simple statement to a compound statement. And place cursor above prev line.
noremap <M-k> ddko{<C-m>}<Esc>kpo             Same as above but place cursor below old line.

vnoremap <M-j> <Esc>                  
vnoremap <M-c> di/*<C-m>/<C-m><Esc>kkp           Commented selected text



nmap <M-n> :noh<CR>                       No hilight


Bye,
    Nithin.

 rate this tip  Life Changing Helpful Unfulfilling 

<<Help for VIM Help (VIM QuickRef) | Vim in Microsoft Visual Foxpro >>

Additional Notes

[email protected], September 20, 2002 1:57
Hello Nithin,

I was baffled to read that you are attempting to reduce your hand movements to the minimum [with these key mappings] while you are typing. Surely you know that this makes you a very good candidate for RSI (Repetitive Strain Injury). Experts recommend that the hands "float" over the keyboard, with the fingers as straight as possible -- instead of curled -- and using full arm movements --instead of finger and wrist contortions. This supposedly helps your arms and hands maintain a natural orientation.

As a professional, I am very concerned with these issues and I try to follow preventive measures against RSI as much as possible. I recommend others to do the same. Nevertheless, your tip was a good start for me to learn about key mappings.

Regards,

Eddy Young
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