blob: fb29237e9f1cb0026d01c67b76c7a97cefcc7cd9 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Set options and add mapping such that Vim behaves a lot like MS-Windows
2"
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00004" Last change: 2006 Mar 28
Bram Moolenaar269ec652004-07-29 08:43:53 +00005
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
Bram Moolenaar071d4272004-06-13 20:20:40 +000010
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.
Bram Moolenaar1056d982006-03-09 22:37:52 +000044" Uses the paste.vim autoload script.
45
46exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
47exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
48
Bram Moolenaar071d4272004-06-13 20:20:40 +000049imap <S-Insert> <C-V>
50vmap <S-Insert> <C-V>
51
52" Use CTRL-Q to do what CTRL-V used to do
53noremap <C-Q> <C-V>
54
55" Use CTRL-S for saving, also in Insert mode
56noremap <C-S> :update<CR>
57vnoremap <C-S> <C-C>:update<CR>
58inoremap <C-S> <C-O>:update<CR>
59
60" For CTRL-V to work autoselect must be off.
61" On Unix we have two selections, autoselect can be used.
62if !has("unix")
63 set guioptions-=a
64endif
65
66" CTRL-Z is Undo; not in cmdline though
67noremap <C-Z> u
68inoremap <C-Z> <C-O>u
69
70" CTRL-Y is Redo (although not repeat); not in cmdline though
71noremap <C-Y> <C-R>
72inoremap <C-Y> <C-O><C-R>
73
74" Alt-Space is System menu
75if has("gui")
76 noremap <M-Space> :simalt ~<CR>
77 inoremap <M-Space> <C-O>:simalt ~<CR>
78 cnoremap <M-Space> <C-C>:simalt ~<CR>
79endif
80
81" CTRL-A is Select all
82noremap <C-A> gggH<C-O>G
83inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
84cnoremap <C-A> <C-C>gggH<C-O>G
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000085onoremap <C-A> <C-C>gggH<C-O>G
Bram Moolenaar071d4272004-06-13 20:20:40 +000086
87" CTRL-Tab is Next window
88noremap <C-Tab> <C-W>w
89inoremap <C-Tab> <C-O><C-W>w
90cnoremap <C-Tab> <C-C><C-W>w
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000091onoremap <C-Tab> <C-C><C-W>w
Bram Moolenaar071d4272004-06-13 20:20:40 +000092
93" CTRL-F4 is Close window
94noremap <C-F4> <C-W>c
95inoremap <C-F4> <C-O><C-W>c
96cnoremap <C-F4> <C-C><C-W>c
Bram Moolenaard2cec5b2006-03-28 21:08:56 +000097onoremap <C-F4> <C-C><C-W>c
Bram Moolenaar071d4272004-06-13 20:20:40 +000098
99" restore 'cpoptions'
100set cpo&
101if 1
102 let &cpoptions = s:save_cpo
103 unlet s:save_cpo
104endif