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