7
|
1 " Set options and add mapping such that Vim behaves a lot like MS-Windows
|
|
2 "
|
|
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
|
654
|
4 " Last change: 2006 Feb 02
|
21
|
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
|
7
|
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.
|
|
44 " Note: the same stuff appears in menu.vim.
|
|
45 if has("virtualedit")
|
|
46 nnoremap <silent> <SID>Paste :call <SID>Paste()<CR>
|
|
47 func! <SID>Paste()
|
|
48 let ove = &ve
|
|
49 set ve=all
|
654
|
50 normal! `^
|
7
|
51 if @+ != ''
|
654
|
52 normal! "+gP
|
7
|
53 endif
|
|
54 let c = col(".")
|
654
|
55 normal! i
|
7
|
56 if col(".") < c " compensate for i<ESC> moving the cursor left
|
620
|
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=
|
654
|
61 normal! l
|
620
|
62 let &vb = vb_save
|
|
63 let &t_vb = t_vb_save
|
7
|
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
|
|
69 else
|
|
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
|
|
73 endif
|
|
74 imap <S-Insert> <C-V>
|
|
75 vmap <S-Insert> <C-V>
|
|
76
|
|
77 " Use CTRL-Q to do what CTRL-V used to do
|
|
78 noremap <C-Q> <C-V>
|
|
79
|
|
80 " Use CTRL-S for saving, also in Insert mode
|
|
81 noremap <C-S> :update<CR>
|
|
82 vnoremap <C-S> <C-C>:update<CR>
|
|
83 inoremap <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.
|
|
87 if !has("unix")
|
|
88 set guioptions-=a
|
|
89 endif
|
|
90
|
|
91 " CTRL-Z is Undo; not in cmdline though
|
|
92 noremap <C-Z> u
|
|
93 inoremap <C-Z> <C-O>u
|
|
94
|
|
95 " CTRL-Y is Redo (although not repeat); not in cmdline though
|
|
96 noremap <C-Y> <C-R>
|
|
97 inoremap <C-Y> <C-O><C-R>
|
|
98
|
|
99 " Alt-Space is System menu
|
|
100 if has("gui")
|
|
101 noremap <M-Space> :simalt ~<CR>
|
|
102 inoremap <M-Space> <C-O>:simalt ~<CR>
|
|
103 cnoremap <M-Space> <C-C>:simalt ~<CR>
|
|
104 endif
|
|
105
|
|
106 " CTRL-A is Select all
|
|
107 noremap <C-A> gggH<C-O>G
|
|
108 inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
|
|
109 cnoremap <C-A> <C-C>gggH<C-O>G
|
|
110
|
|
111 " CTRL-Tab is Next window
|
|
112 noremap <C-Tab> <C-W>w
|
|
113 inoremap <C-Tab> <C-O><C-W>w
|
|
114 cnoremap <C-Tab> <C-C><C-W>w
|
|
115
|
|
116 " CTRL-F4 is Close window
|
|
117 noremap <C-F4> <C-W>c
|
|
118 inoremap <C-F4> <C-O><C-W>c
|
|
119 cnoremap <C-F4> <C-C><C-W>c
|
|
120
|
|
121 " restore 'cpoptions'
|
|
122 set cpo&
|
|
123 if 1
|
|
124 let &cpoptions = s:save_cpo
|
|
125 unlet s:save_cpo
|
|
126 endif
|