blob: d82b67743b65036bbe3ab061e5b02963709154f9 [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 Moolenaar269ec652004-07-29 08:43:53 +00004" Last change: 2004 Jul 27
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
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.
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 normal l
58 endif
59 let &ve = ove
60 endfunc
61 inoremap <script> <C-V> x<BS><Esc><SID>Pastegi
62 vnoremap <script> <C-V> "-c<Esc><SID>Paste
63else
64 nnoremap <silent> <SID>Paste "=@+.'xy'<CR>gPFx"_2x
65 inoremap <script> <C-V> x<Esc><SID>Paste"_s
66 vnoremap <script> <C-V> "-c<Esc>gix<Esc><SID>Paste"_x
67endif
68imap <S-Insert> <C-V>
69vmap <S-Insert> <C-V>
70
71" Use CTRL-Q to do what CTRL-V used to do
72noremap <C-Q> <C-V>
73
74" Use CTRL-S for saving, also in Insert mode
75noremap <C-S> :update<CR>
76vnoremap <C-S> <C-C>:update<CR>
77inoremap <C-S> <C-O>:update<CR>
78
79" For CTRL-V to work autoselect must be off.
80" On Unix we have two selections, autoselect can be used.
81if !has("unix")
82 set guioptions-=a
83endif
84
85" CTRL-Z is Undo; not in cmdline though
86noremap <C-Z> u
87inoremap <C-Z> <C-O>u
88
89" CTRL-Y is Redo (although not repeat); not in cmdline though
90noremap <C-Y> <C-R>
91inoremap <C-Y> <C-O><C-R>
92
93" Alt-Space is System menu
94if has("gui")
95 noremap <M-Space> :simalt ~<CR>
96 inoremap <M-Space> <C-O>:simalt ~<CR>
97 cnoremap <M-Space> <C-C>:simalt ~<CR>
98endif
99
100" CTRL-A is Select all
101noremap <C-A> gggH<C-O>G
102inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
103cnoremap <C-A> <C-C>gggH<C-O>G
104
105" CTRL-Tab is Next window
106noremap <C-Tab> <C-W>w
107inoremap <C-Tab> <C-O><C-W>w
108cnoremap <C-Tab> <C-C><C-W>w
109
110" CTRL-F4 is Close window
111noremap <C-F4> <C-W>c
112inoremap <C-F4> <C-O><C-W>c
113cnoremap <C-F4> <C-C><C-W>c
114
115" restore 'cpoptions'
116set cpo&
117if 1
118 let &cpoptions = s:save_cpo
119 unlet s:save_cpo
120endif