Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Vim has a terrific paste mode, in which abbreviations and mappings are ignored. Frustratingly, even keys that do not map to pastable ASCII characters, such as the function keys, are pasted literally. For instance the key F2 is pasted as <F2>. Is there anyway around this?

Note that pastetoggle can in fact be mapped to a function key to easily leave paste mode, however the function that I am writing changes other values when entering or leaving paste mode (such as enabling or disabling line numbers and other things). Therefore I would really like to find a workaround.

For reference, here is the current version of the function (that gets stuck in paste mode):

iab if if<Space>(<Space>{{<Esc>kA<Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>

" Triple-toggle Insert Modes: coding, prose, and paste
let g:insertModeGlobal=1
function! Te()

    if g:insertModeGlobal==3
        " Was in paste insert mode, go to coding insert mode

        set nu
        set nopaste

        let g:insertModeGlobal=4

    if g:insertModeGlobal==2
        " Was in prose insert mode, go to paste insert mode

        set nolinebreak
        nnoremap j j 
        nnoremap k k 
        nnoremap gj gj
        nnoremap gk gk
        set relativenumber
        execute ":Signs"
        iab if if<Space>(<Space>{{<Esc>kA<Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>

        set nonu
        set paste

        let g:insertModeGlobal=3

    if g:insertModeGlobal==1
        " Was in coding insert mode, go to prose insert mode

        set linebreak
        nnoremap j gj
        nnoremap k gk
        nnoremap gj j
        nnoremap gk k
        set number
        execute ":DisableSigns"
        iab if if

        let g:insertModeGlobal=2

    if g:insertModeGlobal==4
        let g:insertModeGlobal=1

share|improve this question

Paste mode is not intended for long periods of typing. It exists only to overcome longstanding limitations of Vim when running in a terminal. You should not use it for anything else than pasting text with the middle mouse button.

That's why set pastetoggle="<F12>" exists: Want to paste something? Hit <F12> to enter paste mode, paste, hit <F12> again to exit paste mode.

Alternatively, use "*p or "+p if your version of Vim supports it.

share|improve this answer
Thank you. I don't do any typing in Paste mode, but I do use it often enough that I want to keep it on the three-way toggle with my two other insert modes. Also, it saves me a Function key which is a big help, as I have the others assigned to other things. – dotancohen Aug 31 '12 at 14:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.