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

John Gilmore j.arthur.gilmore at gmail.com
Fri Sep 13 14:41:56 MDT 2013


Thank you, Stephen. <C-O> is indeed what I was looking for.

imap <F7> <C-O>:set spell!<CR>

Does things exactly right. Disappointing that so many references on
the internet get it wrong though.

On Fri, Sep 13, 2013 at 12:35 PM, Stephen Warren <swarren at wwwdotorg.org> wrote:
> 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