Merge branch 'vim-with-runtime' into feat/code-check
[vim_extended.git] / runtime / mswin.vim
blob1ceef847e931021a07e80accf9b865ebe32631c5
1 " Set options and add mapping such that Vim behaves a lot like MS-Windows
3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
4 " Last change:  2006 Apr 02
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
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
17 " set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows
18 behave mswin
20 " backspace and cursor keys wrap to previous/next line
21 set backspace=indent,eol,start whichwrap+=<,>,[,]
23 " backspace in Visual mode deletes selection
24 vnoremap <BS> d
26 " CTRL-X and SHIFT-Del are Cut
27 vnoremap <C-X> "+x
28 vnoremap <S-Del> "+x
30 " CTRL-C and CTRL-Insert are Copy
31 vnoremap <C-C> "+y
32 vnoremap <C-Insert> "+y
34 " CTRL-V and SHIFT-Insert are Paste
35 map <C-V>               "+gP
36 map <S-Insert>          "+gP
38 cmap <C-V>              <C-R>+
39 cmap <S-Insert>         <C-R>+
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 " Uses the paste.vim autoload script.
46 exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
47 exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
49 imap <S-Insert>         <C-V>
50 vmap <S-Insert>         <C-V>
52 " Use CTRL-Q to do what CTRL-V used to do
53 noremap <C-Q>           <C-V>
55 " Use CTRL-S for saving, also in Insert mode
56 noremap <C-S>           :update<CR>
57 vnoremap <C-S>          <C-C>:update<CR>
58 inoremap <C-S>          <C-O>:update<CR>
60 " For CTRL-V to work autoselect must be off.
61 " On Unix we have two selections, autoselect can be used.
62 if !has("unix")
63   set guioptions-=a
64 endif
66 " CTRL-Z is Undo; not in cmdline though
67 noremap <C-Z> u
68 inoremap <C-Z> <C-O>u
70 " CTRL-Y is Redo (although not repeat); not in cmdline though
71 noremap <C-Y> <C-R>
72 inoremap <C-Y> <C-O><C-R>
74 " Alt-Space is System menu
75 if has("gui")
76   noremap <M-Space> :simalt ~<CR>
77   inoremap <M-Space> <C-O>:simalt ~<CR>
78   cnoremap <M-Space> <C-C>:simalt ~<CR>
79 endif
81 " CTRL-A is Select all
82 noremap <C-A> gggH<C-O>G
83 inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
84 cnoremap <C-A> <C-C>gggH<C-O>G
85 onoremap <C-A> <C-C>gggH<C-O>G
86 snoremap <C-A> <C-C>gggH<C-O>G
87 xnoremap <C-A> <C-C>ggVG
89 " CTRL-Tab is Next window
90 noremap <C-Tab> <C-W>w
91 inoremap <C-Tab> <C-O><C-W>w
92 cnoremap <C-Tab> <C-C><C-W>w
93 onoremap <C-Tab> <C-C><C-W>w
95 " CTRL-F4 is Close window
96 noremap <C-F4> <C-W>c
97 inoremap <C-F4> <C-O><C-W>c
98 cnoremap <C-F4> <C-C><C-W>c
99 onoremap <C-F4> <C-C><C-W>c
101 " restore 'cpoptions'
102 set cpo&
103 if 1
104   let &cpoptions = s:save_cpo
105   unlet s:save_cpo
106 endif