[NCLUG] Stupid VIM advice on the net. How to do it right?

Stephen Warren swarren at wwwdotorg.org
Fri Sep 13 12:35:11 MDT 2013


On 09/13/2013 11:00 AM, John Gilmore wrote:
> How do I access normal mode (or command mode) stuff from withing an
> insert mode keymapping?

Command-mode: <C-O>
Normal mode: Not 100% sure, but perhaps <C-O>:norm, :stopinsert?

The following entries from my vimrc might be relevant (it's been a long
time since I wrote or stole these, so I can't say much about what they
do or how, and they may built upon the use of mswin32.vim!):

" Scroll whilst keeping cursor on the same line

noremap <C-Up> <C-Y>
vnoremap <C-Up> <ESC><C-Y>gv
inoremap <C-Up> <C-O><C-Y>

noremap <C-Down> <C-E>
vnoremap <C-Down> <ESC><C-E>gv
inoremap <C-Down> <C-O><C-E>

" Tab/S-Tab to indent/backdent code

xnoremap <Tab> >gv
xnoremap <S-Tab> <gv
snoremap <Tab> <C-O>>`<gh<C-O>`>
snoremap <S-Tab> <C-O><`<gh<C-O>`>

" Make C-S-Left/Right select sane words in (and when entering) \
select mode

inoremap <C-S-Left> <C-O>:stopinsert<CR>gh<C-O>b
inoremap <C-S-Right> <C-O>:stopinsert<CR>gh<C-O>w
nnoremap <C-S-Left> gh<C-O>b
nnoremap <C-S-Right> gh<C-O>w
xnoremap <C-S-Left> b
xnoremap <C-S-Right> w
snoremap <C-S-Left> <C-O>b
snoremap <C-S-Right> <C-O>w



More information about the NCLUG mailing list