robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Christian Clasonfix(runtime): clean up one-off scripts82b02ae2f2

master
4.1 KiB149 linesraw
1" Set options and add mapping such that Vim behaves a lot like MS-Windows
2"
3" Maintainer:	The Vim Project <https://github.com/vim/vim>
4" Last Change:	2024 Mar 13
5" Former Maintainer:	Bram Moolenaar <Bram@vim.org>
6
7" Bail out if this isn't wanted.
8if exists("g:skip_loading_mswin") && g:skip_loading_mswin
9  finish
10endif
11
12" set the 'cpoptions' to its Vim default
13if 1	" only do this when compiled with expression evaluation
14  let s:save_cpo = &cpoptions
15endif
16set cpo&vim
17
18" set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows
19set selection=exclusive
20set selectmode=mouse,key
21set mousemodel=popup
22set keymodel=startsel,stopsel
23
24" backspace and cursor keys wrap to previous/next line
25set backspace=indent,eol,start whichwrap+=<,>,[,]
26
27" backspace in Visual mode deletes selection
28vnoremap <BS> d
29
30" the better solution would be to use has("clipboard_working"),
31" but that may not be available yet while starting up, so let's just check if
32" clipboard support has been compiled in and assume it will be working :/
33if has("clipboard")
34    " CTRL-X and SHIFT-Del are Cut
35    vnoremap <C-X> "+x
36    vnoremap <S-Del> "+x
37
38    " CTRL-C and CTRL-Insert are Copy
39    vnoremap <C-C> "+y
40    vnoremap <C-Insert> "+y
41
42    " CTRL-V and SHIFT-Insert are Paste
43    map <C-V>		"+gP
44    map <S-Insert>		"+gP
45
46    cmap <C-V>		<C-R>+
47    cmap <S-Insert>		<C-R>+
48else
49		" Use the unnamed register when clipboard support not available
50
51    " CTRL-X and SHIFT-Del are Cut
52    vnoremap <C-X>   x
53    vnoremap <S-Del> x
54
55    " CTRL-C and CTRL-Insert are Copy
56    vnoremap <C-C>      y
57    vnoremap <C-Insert> y
58
59    " CTRL-V and SHIFT-Insert are Paste
60    noremap <C-V>      gP
61    noremap <S-Insert> gP
62
63    inoremap <C-V>      <C-R>"
64    inoremap <S-Insert> <C-R>"
65endif
66
67" Pasting blockwise and linewise selections is not possible in Insert and
68" Visual mode without the +virtualedit feature.  They are pasted as if they
69" were characterwise instead.
70" Uses the paste.vim autoload script.
71" Use CTRL-G u to have CTRL-Z only undo the paste.
72
73if has("clipboard")
74    exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i']
75    exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v']
76endif
77
78imap <S-Insert>		<C-V>
79vmap <S-Insert>		<C-V>
80
81" Use CTRL-Q to do what CTRL-V used to do
82noremap <C-Q>		<C-V>
83
84" Use CTRL-S for saving, also in Insert mode (<C-O> doesn't work well when
85" using completions).
86noremap <C-S>		:update<CR>
87vnoremap <C-S>		<C-C>:update<CR>
88inoremap <C-S>		<Esc>:update<CR>gi
89
90" For CTRL-V to work autoselect must be off.
91" On Unix we have two selections, autoselect can be used.
92if !has("unix")
93  set guioptions-=a
94endif
95
96" CTRL-Z is Undo; not in cmdline though
97noremap <C-Z> u
98inoremap <C-Z> <C-O>u
99
100" CTRL-Y is Redo (although not repeat); not in cmdline though
101noremap <C-Y> <C-R>
102inoremap <C-Y> <C-O><C-R>
103
104" Alt-Space is System menu
105if has("gui")
106  noremap <M-Space> :simalt ~<CR>
107  inoremap <M-Space> <C-O>:simalt ~<CR>
108  cnoremap <M-Space> <C-C>:simalt ~<CR>
109endif
110
111" CTRL-A is Select all
112noremap <C-A> gggH<C-O>G
113inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
114cnoremap <C-A> <C-C>gggH<C-O>G
115onoremap <C-A> <C-C>gggH<C-O>G
116snoremap <C-A> <C-C>gggH<C-O>G
117xnoremap <C-A> <C-C>ggVG
118
119" CTRL-Tab is Next window
120noremap <C-Tab> <C-W>w
121inoremap <C-Tab> <C-O><C-W>w
122cnoremap <C-Tab> <C-C><C-W>w
123onoremap <C-Tab> <C-C><C-W>w
124
125" CTRL-F4 is Close window
126noremap <C-F4> <C-W>c
127inoremap <C-F4> <C-O><C-W>c
128cnoremap <C-F4> <C-C><C-W>c
129onoremap <C-F4> <C-C><C-W>c
130
131if has("gui")
132  " CTRL-F is the search dialog
133  noremap  <expr> <C-F> has("gui_running") ? ":promptfind\<CR>" : "/"
134  inoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-O>:promptfind\<CR>" : "\<C-\>\<C-O>/"
135  cnoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-C>:promptfind\<CR>" : "\<C-\>\<C-O>/"
136
137  " CTRL-H is the replace dialog,
138  " but in console, it might be backspace, so don't map it there
139  nnoremap <expr> <C-H> has("gui_running") ? ":promptrepl\<CR>" : "\<C-H>"
140  inoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-O>:promptrepl\<CR>" : "\<C-H>"
141  cnoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-C>:promptrepl\<CR>" : "\<C-H>"
142endif
143
144" restore 'cpoptions'
145set cpo&
146if 1
147  let &cpoptions = s:save_cpo
148  unlet s:save_cpo
149endif