annotate runtime/mswin.vim @ 33791:370543108ba1 v9.0.2114

patch 9.0.2114: overflow detection not accurate when adding digits Commit: https://github.com/vim/vim/commit/22cbc8a4e17ce61aa460c451a26e1bff2c3d2af9 Author: Christian Brabandt <cb@256bit.org> Date: Sun Nov 19 10:47:21 2023 +0100 patch 9.0.2114: overflow detection not accurate when adding digits Problem: overflow detection not accurate when adding digits Solution: Use a helper function Use a helper function to better detect overflows before adding integer digits to a long or an integer variable respectively. Signal the overflow to the caller function. closes: #13539 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Michael Henry <vim@drmikehenry.com> Signed-off-by: Ernie Rael <errael@raelity.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 19 Nov 2023 11:00:07 +0100
parents 4027cefc2aab
children 1d0b21fc9df1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Set options and add mapping such that Vim behaves a lot like MS-Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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>
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 15131
diff changeset
4 " Last Change: 2023 Aug 10
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
db5102f7e29f updated for version 7.0013
vimboss
parents: 7
diff changeset
6
15131
bc1a8d21c811 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14372
diff changeset
7 " Bail out if this isn't wanted.
21
db5102f7e29f updated for version 7.0013
vimboss
parents: 7
diff changeset
8 if exists("g:skip_loading_mswin") && g:skip_loading_mswin
db5102f7e29f updated for version 7.0013
vimboss
parents: 7
diff changeset
9 finish
db5102f7e29f updated for version 7.0013
vimboss
parents: 7
diff changeset
10 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " set the 'cpoptions' to its Vim default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if 1 " only do this when compiled with expression evaluation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let s:save_cpo = &cpoptions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 set cpo&vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 behave mswin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " backspace and cursor keys wrap to previous/next line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 set backspace=indent,eol,start whichwrap+=<,>,[,]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " backspace in Visual mode deletes selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 vnoremap <BS> d
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
27 if has("clipboard")
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
28 " 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
29 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
30 vnoremap <S-Del> "+x
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
32 " 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
33 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
34 vnoremap <C-Insert> "+y
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
36 " 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
37 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
38 map <S-Insert> "+gP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
40 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
41 cmap <S-Insert> <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
42 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " Pasting blockwise and linewise selections is not possible in Insert and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " Visual mode without the +virtualedit feature. They are pasted as if they
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " were characterwise instead.
720
e180933b876a updated for version 7.0219
vimboss
parents: 654
diff changeset
47 " Uses the paste.vim autoload script.
3682
11d40fc82f11 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 819
diff changeset
48 " Use CTRL-G u to have CTRL-Z only undo the paste.
720
e180933b876a updated for version 7.0219
vimboss
parents: 654
diff changeset
49
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
50 if 1
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
51 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
52 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
53 endif
720
e180933b876a updated for version 7.0219
vimboss
parents: 654
diff changeset
54
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 imap <S-Insert> <C-V>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 vmap <S-Insert> <C-V>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " Use CTRL-Q to do what CTRL-V used to do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 noremap <C-Q> <C-V>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12708
diff changeset
61 " Use CTRL-S for saving, also in Insert mode (<C-O> doesn't work well when
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12708
diff changeset
62 " using completions).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 noremap <C-S> :update<CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 vnoremap <C-S> <C-C>:update<CR>
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12708
diff changeset
65 inoremap <C-S> <Esc>:update<CR>gi
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " For CTRL-V to work autoselect must be off.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " On Unix we have two selections, autoselect can be used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if !has("unix")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 set guioptions-=a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " CTRL-Z is Undo; not in cmdline though
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 noremap <C-Z> u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 inoremap <C-Z> <C-O>u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " CTRL-Y is Redo (although not repeat); not in cmdline though
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 noremap <C-Y> <C-R>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 inoremap <C-Y> <C-O><C-R>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 " Alt-Space is System menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 if has("gui")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 noremap <M-Space> :simalt ~<CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 inoremap <M-Space> <C-O>:simalt ~<CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 cnoremap <M-Space> <C-C>:simalt ~<CR>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 " CTRL-A is Select all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 noremap <C-A> gggH<C-O>G
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 cnoremap <C-A> <C-C>gggH<C-O>G
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 720
diff changeset
92 onoremap <C-A> <C-C>gggH<C-O>G
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 816
diff changeset
93 snoremap <C-A> <C-C>gggH<C-O>G
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 816
diff changeset
94 xnoremap <C-A> <C-C>ggVG
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 " CTRL-Tab is Next window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 noremap <C-Tab> <C-W>w
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 inoremap <C-Tab> <C-O><C-W>w
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 cnoremap <C-Tab> <C-C><C-W>w
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 720
diff changeset
100 onoremap <C-Tab> <C-C><C-W>w
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " CTRL-F4 is Close window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 noremap <C-F4> <C-W>c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 inoremap <C-F4> <C-O><C-W>c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 cnoremap <C-F4> <C-C><C-W>c
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 720
diff changeset
106 onoremap <C-F4> <C-C><C-W>c
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
10863
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
108 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
109 " 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
110 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
111 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
112 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
113
12708
77960063e2e7 patch 8.0.1232: MS-Windows users are confused about default mappings
Christian Brabandt <cb@256bit.org>
parents: 10863
diff changeset
114 " 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
115 " 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
116 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
117 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
118 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
119 endif
9130644aec5c patch 8.0.0321: errors when trying to use scripts in tiny version
Christian Brabandt <cb@256bit.org>
parents: 3713
diff changeset
120
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 " restore 'cpoptions'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 set cpo&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 let &cpoptions = s:save_cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 unlet s:save_cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 endif