Mercurial > vim
annotate runtime/mswin.vim @ 34545:e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Commit: https://github.com/vim/vim/commit/760f664213dea9a300454992ba1589f4601d622f
Author: Christian Brabandt <cb@256bit.org>
Date: Wed Mar 13 16:38:16 2024 +0100
runtime(mswin): revert back the check for clipboard_working support
Commit d9ebd46bd090c598adc82e6 changed the condition to
check if the clipboard is available from:
```
has('clipboard')
```
to
```
has('clipboard_working')
```
Assuming that is the more accurate test because even when clipboard
support is enabled at compile time it may not be actually working (e.g.
if no X11 environment is available, or when working on a remote server).
However it seems that condition does not evaluate to true, when the GUI
has not been started up yet (and there was no X11 Connection yet possible).
So let's just revert back the check to `has('clipboard')`, since that
has been proven to be working well enough.
related: #13809
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 13 Mar 2024 16:45:07 +0100 |
parents | 1d0b21fc9df1 |
children | 91428f34746f |
rev | line source |
---|---|
7 | 1 " Set options and add mapping such that Vim behaves a lot like MS-Windows |
2 " | |
32770
4027cefc2aab
Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents:
15131
diff
changeset
|
3 " Maintainer: The Vim Project <https://github.com/vim/vim> |
34545
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
4 " Last Change: 2024 Mar 13 |
32770
4027cefc2aab
Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents:
15131
diff
changeset
|
5 " Former Maintainer: Bram Moolenaar <Bram@vim.org> |
21 | 6 |
15131 | 7 " Bail out if this isn't wanted. |
21 | 8 if exists("g:skip_loading_mswin") && g:skip_loading_mswin |
9 finish | |
10 endif | |
7 | 11 |
12 " set the 'cpoptions' to its Vim default | |
13 if 1 " only do this when compiled with expression evaluation | |
14 let s:save_cpo = &cpoptions | |
15 endif | |
16 set cpo&vim | |
17 | |
18 " set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows | |
19 behave mswin | |
20 | |
21 " backspace and cursor keys wrap to previous/next line | |
22 set backspace=indent,eol,start whichwrap+=<,>,[,] | |
23 | |
24 " backspace in Visual mode deletes selection | |
25 vnoremap <BS> d | |
26 | |
34545
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
27 " the better solution would be to use has("clipboard_working"), |
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
28 " but that may not be available yet while starting up, so let's just check if |
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
29 " clipboard support has been compiled in and assume it will be working :/ |
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
30 if has("clipboard") |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
31 " CTRL-X and SHIFT-Del are Cut |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
32 vnoremap <C-X> "+x |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
33 vnoremap <S-Del> "+x |
7 | 34 |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
35 " CTRL-C and CTRL-Insert are Copy |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
36 vnoremap <C-C> "+y |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
37 vnoremap <C-Insert> "+y |
7 | 38 |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
39 " CTRL-V and SHIFT-Insert are Paste |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
40 map <C-V> "+gP |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
41 map <S-Insert> "+gP |
7 | 42 |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
43 cmap <C-V> <C-R>+ |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
44 cmap <S-Insert> <C-R>+ |
34474
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
45 else |
34545
e893892758b7
runtime(mswin): revert back the check for clipboard_working support
Christian Brabandt <cb@256bit.org>
parents:
34474
diff
changeset
|
46 " Use the unnamed register when clipboard support not available |
34474
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
47 |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
48 " CTRL-X and SHIFT-Del are Cut |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
49 vnoremap <C-X> x |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
50 vnoremap <S-Del> x |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
51 |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
52 " CTRL-C and CTRL-Insert are Copy |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
53 vnoremap <C-C> y |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
54 vnoremap <C-Insert> y |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
55 |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
56 " CTRL-V and SHIFT-Insert are Paste |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
57 noremap <C-V> gP |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
58 noremap <S-Insert> gP |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
59 |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
60 inoremap <C-V> <C-R>" |
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
61 inoremap <S-Insert> <C-R>" |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
62 endif |
7 | 63 |
64 " Pasting blockwise and linewise selections is not possible in Insert and | |
65 " Visual mode without the +virtualedit feature. They are pasted as if they | |
66 " were characterwise instead. | |
720 | 67 " Uses the paste.vim autoload script. |
3682 | 68 " Use CTRL-G u to have CTRL-Z only undo the paste. |
720 | 69 |
34474
1d0b21fc9df1
runtime(mswin): Use unnamed register when clipboard not working (#13813)
Christian Brabandt <cb@256bit.org>
parents:
32770
diff
changeset
|
70 if has("clipboard_working") |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
71 exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i'] |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
72 exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v'] |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
73 endif |
720 | 74 |
7 | 75 imap <S-Insert> <C-V> |
76 vmap <S-Insert> <C-V> | |
77 | |
78 " Use CTRL-Q to do what CTRL-V used to do | |
79 noremap <C-Q> <C-V> | |
80 | |
14372 | 81 " Use CTRL-S for saving, also in Insert mode (<C-O> doesn't work well when |
82 " using completions). | |
7 | 83 noremap <C-S> :update<CR> |
84 vnoremap <C-S> <C-C>:update<CR> | |
14372 | 85 inoremap <C-S> <Esc>:update<CR>gi |
7 | 86 |
87 " For CTRL-V to work autoselect must be off. | |
88 " On Unix we have two selections, autoselect can be used. | |
89 if !has("unix") | |
90 set guioptions-=a | |
91 endif | |
92 | |
93 " CTRL-Z is Undo; not in cmdline though | |
94 noremap <C-Z> u | |
95 inoremap <C-Z> <C-O>u | |
96 | |
97 " CTRL-Y is Redo (although not repeat); not in cmdline though | |
98 noremap <C-Y> <C-R> | |
99 inoremap <C-Y> <C-O><C-R> | |
100 | |
101 " Alt-Space is System menu | |
102 if has("gui") | |
103 noremap <M-Space> :simalt ~<CR> | |
104 inoremap <M-Space> <C-O>:simalt ~<CR> | |
105 cnoremap <M-Space> <C-C>:simalt ~<CR> | |
106 endif | |
107 | |
108 " CTRL-A is Select all | |
109 noremap <C-A> gggH<C-O>G | |
110 inoremap <C-A> <C-O>gg<C-O>gH<C-O>G | |
111 cnoremap <C-A> <C-C>gggH<C-O>G | |
816 | 112 onoremap <C-A> <C-C>gggH<C-O>G |
819 | 113 snoremap <C-A> <C-C>gggH<C-O>G |
114 xnoremap <C-A> <C-C>ggVG | |
7 | 115 |
116 " CTRL-Tab is Next window | |
117 noremap <C-Tab> <C-W>w | |
118 inoremap <C-Tab> <C-O><C-W>w | |
119 cnoremap <C-Tab> <C-C><C-W>w | |
816 | 120 onoremap <C-Tab> <C-C><C-W>w |
7 | 121 |
122 " CTRL-F4 is Close window | |
123 noremap <C-F4> <C-W>c | |
124 inoremap <C-F4> <C-O><C-W>c | |
125 cnoremap <C-F4> <C-C><C-W>c | |
816 | 126 onoremap <C-F4> <C-C><C-W>c |
7 | 127 |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
128 if has("gui") |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
129 " CTRL-F is the search dialog |
12708
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
130 noremap <expr> <C-F> has("gui_running") ? ":promptfind\<CR>" : "/" |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
131 inoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-O>:promptfind\<CR>" : "\<C-\>\<C-O>/" |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
132 cnoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-C>:promptfind\<CR>" : "\<C-\>\<C-O>/" |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
133 |
12708
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
134 " CTRL-H is the replace dialog, |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
135 " but in console, it might be backspace, so don't map it there |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
136 nnoremap <expr> <C-H> has("gui_running") ? ":promptrepl\<CR>" : "\<C-H>" |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
137 inoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-O>:promptrepl\<CR>" : "\<C-H>" |
77960063e2e7
patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents:
10863
diff
changeset
|
138 cnoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-C>:promptrepl\<CR>" : "\<C-H>" |
10863
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
139 endif |
9130644aec5c
patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents:
3713
diff
changeset
|
140 |
7 | 141 " restore 'cpoptions' |
142 set cpo& | |
143 if 1 | |
144 let &cpoptions = s:save_cpo | |
145 unlet s:save_cpo | |
146 endif |