Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Set options and add mapping such that Vim behaves a lot like MS-Windows |
| 2 | " |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 6c35bea | 2012-07-25 17:49:10 +0200 | [diff] [blame] | 4 | " Last change: 2012 Jul 25 |
Bram Moolenaar | 269ec65 | 2004-07-29 08:43:53 +0000 | [diff] [blame] | 5 | |
| 6 | " bail out if this isn't wanted (mrsvim.vim uses this). |
| 7 | if exists("g:skip_loading_mswin") && g:skip_loading_mswin |
| 8 | finish |
| 9 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 10 | |
| 11 | " set the 'cpoptions' to its Vim default |
| 12 | if 1 " only do this when compiled with expression evaluation |
| 13 | let s:save_cpo = &cpoptions |
| 14 | endif |
| 15 | set cpo&vim |
| 16 | |
| 17 | " set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows |
| 18 | behave mswin |
| 19 | |
| 20 | " backspace and cursor keys wrap to previous/next line |
| 21 | set backspace=indent,eol,start whichwrap+=<,>,[,] |
| 22 | |
| 23 | " backspace in Visual mode deletes selection |
| 24 | vnoremap <BS> d |
| 25 | |
| 26 | " CTRL-X and SHIFT-Del are Cut |
| 27 | vnoremap <C-X> "+x |
| 28 | vnoremap <S-Del> "+x |
| 29 | |
| 30 | " CTRL-C and CTRL-Insert are Copy |
| 31 | vnoremap <C-C> "+y |
| 32 | vnoremap <C-Insert> "+y |
| 33 | |
| 34 | " CTRL-V and SHIFT-Insert are Paste |
| 35 | map <C-V> "+gP |
| 36 | map <S-Insert> "+gP |
| 37 | |
| 38 | cmap <C-V> <C-R>+ |
| 39 | cmap <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. |
Bram Moolenaar | 1056d98 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 44 | " Uses the paste.vim autoload script. |
Bram Moolenaar | 30b6581 | 2012-07-12 22:01:11 +0200 | [diff] [blame] | 45 | " Use CTRL-G u to have CTRL-Z only undo the paste. |
Bram Moolenaar | 1056d98 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 46 | |
Bram Moolenaar | 30b6581 | 2012-07-12 22:01:11 +0200 | [diff] [blame] | 47 | exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i'] |
Bram Moolenaar | 6c35bea | 2012-07-25 17:49:10 +0200 | [diff] [blame] | 48 | exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v'] |
Bram Moolenaar | 1056d98 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 49 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 50 | imap <S-Insert> <C-V> |
| 51 | vmap <S-Insert> <C-V> |
| 52 | |
| 53 | " Use CTRL-Q to do what CTRL-V used to do |
| 54 | noremap <C-Q> <C-V> |
| 55 | |
| 56 | " Use CTRL-S for saving, also in Insert mode |
| 57 | noremap <C-S> :update<CR> |
| 58 | vnoremap <C-S> <C-C>:update<CR> |
| 59 | inoremap <C-S> <C-O>:update<CR> |
| 60 | |
| 61 | " For CTRL-V to work autoselect must be off. |
| 62 | " On Unix we have two selections, autoselect can be used. |
| 63 | if !has("unix") |
| 64 | set guioptions-=a |
| 65 | endif |
| 66 | |
| 67 | " CTRL-Z is Undo; not in cmdline though |
| 68 | noremap <C-Z> u |
| 69 | inoremap <C-Z> <C-O>u |
| 70 | |
| 71 | " CTRL-Y is Redo (although not repeat); not in cmdline though |
| 72 | noremap <C-Y> <C-R> |
| 73 | inoremap <C-Y> <C-O><C-R> |
| 74 | |
| 75 | " Alt-Space is System menu |
| 76 | if has("gui") |
| 77 | noremap <M-Space> :simalt ~<CR> |
| 78 | inoremap <M-Space> <C-O>:simalt ~<CR> |
| 79 | cnoremap <M-Space> <C-C>:simalt ~<CR> |
| 80 | endif |
| 81 | |
| 82 | " CTRL-A is Select all |
| 83 | noremap <C-A> gggH<C-O>G |
| 84 | inoremap <C-A> <C-O>gg<C-O>gH<C-O>G |
| 85 | cnoremap <C-A> <C-C>gggH<C-O>G |
Bram Moolenaar | d2cec5b | 2006-03-28 21:08:56 +0000 | [diff] [blame] | 86 | onoremap <C-A> <C-C>gggH<C-O>G |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 87 | snoremap <C-A> <C-C>gggH<C-O>G |
| 88 | xnoremap <C-A> <C-C>ggVG |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | |
| 90 | " CTRL-Tab is Next window |
| 91 | noremap <C-Tab> <C-W>w |
| 92 | inoremap <C-Tab> <C-O><C-W>w |
| 93 | cnoremap <C-Tab> <C-C><C-W>w |
Bram Moolenaar | d2cec5b | 2006-03-28 21:08:56 +0000 | [diff] [blame] | 94 | onoremap <C-Tab> <C-C><C-W>w |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 95 | |
| 96 | " CTRL-F4 is Close window |
| 97 | noremap <C-F4> <C-W>c |
| 98 | inoremap <C-F4> <C-O><C-W>c |
| 99 | cnoremap <C-F4> <C-C><C-W>c |
Bram Moolenaar | d2cec5b | 2006-03-28 21:08:56 +0000 | [diff] [blame] | 100 | onoremap <C-F4> <C-C><C-W>c |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 101 | |
| 102 | " restore 'cpoptions' |
| 103 | set cpo& |
| 104 | if 1 |
| 105 | let &cpoptions = s:save_cpo |
| 106 | unlet s:save_cpo |
| 107 | endif |