1" Set options and add mapping such that Vim behaves a lot like MS-Windows 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last change: 2005 Dec 28 5 6" bail out if this isn't wanted (mrsvim.vim uses this). 7if exists("g:skip_loading_mswin") && g:skip_loading_mswin 8 finish 9endif 10 11" set the 'cpoptions' to its Vim default 12if 1 " only do this when compiled with expression evaluation 13 let s:save_cpo = &cpoptions 14endif 15set cpo&vim 16 17" set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows 18behave mswin 19 20" backspace and cursor keys wrap to previous/next line 21set backspace=indent,eol,start whichwrap+=<,>,[,] 22 23" backspace in Visual mode deletes selection 24vnoremap <BS> d 25 26" CTRL-X and SHIFT-Del are Cut 27vnoremap <C-X> "+x 28vnoremap <S-Del> "+x 29 30" CTRL-C and CTRL-Insert are Copy 31vnoremap <C-C> "+y 32vnoremap <C-Insert> "+y 33 34" CTRL-V and SHIFT-Insert are Paste 35map <C-V> "+gP 36map <S-Insert> "+gP 37 38cmap <C-V> <C-R>+ 39cmap <S-Insert> <C-R>+ 40 41" Pasting blockwise and linewise selections is not possible in Insert and 42" Visual mode without the +virtualedit feature. They are pasted as if they 43" were characterwise instead. 44" Note: the same stuff appears in menu.vim. 45if has("virtualedit") 46 nnoremap <silent> <SID>Paste :call <SID>Paste()<CR> 47 func! <SID>Paste() 48 let ove = &ve 49 set ve=all 50 normal `^ 51 if @+ != '' 52 normal "+gP 53 endif 54 let c = col(".") 55 normal i 56 if col(".") < c " compensate for i<ESC> moving the cursor left 57 " Avoid a beep when the text ends at the window edge. 58 let vb_save = &vb 59 let t_vb_save = &t_vb 60 set vb t_vb= 61 normal l 62 let &vb = vb_save 63 let &t_vb = t_vb_save 64 endif 65 let &ve = ove 66 endfunc 67 inoremap <script> <C-V> x<BS><Esc><SID>Pastegi 68 vnoremap <script> <C-V> "-c<Esc><SID>Paste 69else 70 nnoremap <silent> <SID>Paste "=@+.'xy'<CR>gPFx"_2x 71 inoremap <script> <C-V> x<Esc><SID>Paste"_s 72 vnoremap <script> <C-V> "-c<Esc>gix<Esc><SID>Paste"_x 73endif 74imap <S-Insert> <C-V> 75vmap <S-Insert> <C-V> 76 77" Use CTRL-Q to do what CTRL-V used to do 78noremap <C-Q> <C-V> 79 80" Use CTRL-S for saving, also in Insert mode 81noremap <C-S> :update<CR> 82vnoremap <C-S> <C-C>:update<CR> 83inoremap <C-S> <C-O>:update<CR> 84 85" For CTRL-V to work autoselect must be off. 86" On Unix we have two selections, autoselect can be used. 87if !has("unix") 88 set guioptions-=a 89endif 90 91" CTRL-Z is Undo; not in cmdline though 92noremap <C-Z> u 93inoremap <C-Z> <C-O>u 94 95" CTRL-Y is Redo (although not repeat); not in cmdline though 96noremap <C-Y> <C-R> 97inoremap <C-Y> <C-O><C-R> 98 99" Alt-Space is System menu 100if has("gui") 101 noremap <M-Space> :simalt ~<CR> 102 inoremap <M-Space> <C-O>:simalt ~<CR> 103 cnoremap <M-Space> <C-C>:simalt ~<CR> 104endif 105 106" CTRL-A is Select all 107noremap <C-A> gggH<C-O>G 108inoremap <C-A> <C-O>gg<C-O>gH<C-O>G 109cnoremap <C-A> <C-C>gggH<C-O>G 110 111" CTRL-Tab is Next window 112noremap <C-Tab> <C-W>w 113inoremap <C-Tab> <C-O><C-W>w 114cnoremap <C-Tab> <C-C><C-W>w 115 116" CTRL-F4 is Close window 117noremap <C-F4> <C-W>c 118inoremap <C-F4> <C-O><C-W>c 119cnoremap <C-F4> <C-C><C-W>c 120 121" restore 'cpoptions' 122set cpo& 123if 1 124 let &cpoptions = s:save_cpo 125 unlet s:save_cpo 126endif 127