50
50
" Internal Mappings
51
51
" ===============================================================================
52
52
53
- inoremap <silent> <Plug> (i) <C-o> :call <SID> process_user_inut ()<CR>
54
- nnoremap <silent> <Plug> (i) :call <SID> process_user_inut ()<CR>
55
- xnoremap <silent> <Plug> (i) :<C-u> call <SID> process_user_inut ()<CR>
53
+ inoremap <silent> <Plug> (i) <C-o> :call <SID> process_user_input ()<CR>
54
+ nnoremap <silent> <Plug> (i) :call <SID> process_user_input ()<CR>
55
+ xnoremap <silent> <Plug> (i) :<C-u> call <SID> process_user_input ()<CR>
56
56
57
57
inoremap <silent> <Plug> (a) <C-o> :call <SID> apply_user_input_next('i')<CR>
58
58
nnoremap <silent> <Plug> (a) :call <SID> apply_user_input_next('n')<CR>
@@ -97,8 +97,8 @@ endfunction
97
97
" attempted to be created at the next occurrence of the visual selection
98
98
function ! multiple_cursors#new (mode )
99
99
if a: mode == # ' n'
100
- " Reset all existing cursors, don't restore view
101
- call s: cm .reset (0 )
100
+ " Reset all existing cursors, don't restore view and setting
101
+ call s: cm .reset (0 , 0 )
102
102
103
103
" Select the word under cursor to set the '< and '> marks
104
104
exec " normal! viw"
@@ -113,7 +113,7 @@ function! multiple_cursors#new(mode)
113
113
let start = line (" '<" )
114
114
let finish = line (" '>" )
115
115
if start != finish
116
- call s: cm .reset (0 )
116
+ call s: cm .reset (0 , 0 )
117
117
let col = col (" '<" )
118
118
for line in range (line (" '<" ), line (" '>" ))
119
119
let pos = [line , col ]
@@ -124,7 +124,7 @@ function! multiple_cursors#new(mode)
124
124
else
125
125
" Came directly from visual mode
126
126
if s: cm .is_empty ()
127
- call s: cm .reset (0 )
127
+ call s: cm .reset (0 , 0 )
128
128
129
129
if visualmode () == # ' V'
130
130
let left = [line (' .' ), 1 ]
@@ -133,7 +133,7 @@ function! multiple_cursors#new(mode)
133
133
return
134
134
endif
135
135
call s: cm .add (right , [left , right ])
136
- else
136
+ else
137
137
call s: cm .add (s: pos (" '>" ), s: region (" '<" , " '>" ))
138
138
endif
139
139
endif
@@ -219,7 +219,7 @@ function! multiple_cursors#find(start, end, pattern)
219
219
call winrestview (s: cm .saved_winview)
220
220
echohl ErrorMsg | echo ' No match found' | echohl None
221
221
return
222
- else
222
+ else
223
223
echohl Normal | echo ' Added ' .s: cm .size ().' cursor' .(s: cm .size ()>1 ?' s' :' ' ) | echohl None
224
224
call s: wait_for_user_input (' v' )
225
225
endif
@@ -318,6 +318,7 @@ function! s:CursorManager.new()
318
318
\ ' virtualedit' : &virtualedit ,
319
319
\ ' cursorline' : &cursorline ,
320
320
\ ' lazyredraw' : &lazyredraw ,
321
+ \ ' paste' : &paste ,
321
322
\ }
322
323
" We save the window view when multicursor mode is entered
323
324
let obj.saved_winview = []
@@ -327,7 +328,7 @@ function! s:CursorManager.new()
327
328
endfunction
328
329
329
330
" Clear all cursors and their highlights
330
- function ! s: CursorManager .reset (restore_view) dict
331
+ function ! s: CursorManager .reset (restore_view, restore_setting ) dict
331
332
if a: restore_view
332
333
" Return the view back to the beginning
333
334
if ! empty (self .saved_winview)
@@ -357,7 +358,9 @@ function! s:CursorManager.reset(restore_view) dict
357
358
let self .saved_winview = []
358
359
let self .start_from_find = 0
359
360
let s: char = ' '
360
- call self .restore_user_settings ()
361
+ if a: restore_setting
362
+ call self .restore_user_settings ()
363
+ endif
361
364
endfunction
362
365
363
366
" Returns 0 if it's not managing any cursors at the moment
@@ -513,10 +516,17 @@ endfunction
513
516
" where the real vim cursor is
514
517
" lazyredraw needs to be turned on to prevent jerky screen behavior with many
515
518
" cursors on screen
519
+ " paste mode needs to be switched off since it turns off a bunch of features
520
+ " that's critical for the plugin to function
516
521
function ! s: CursorManager .initialize () dict
522
+ let self .saved_settings[' virtualedit' ] = &virtualedit
523
+ let self .saved_settings[' cursorline' ] = &cursorline
524
+ let self .saved_settings[' lazyredraw' ] = &lazyredraw
525
+ let self .saved_settings[' paste' ] = &paste
517
526
let &virtualedit = " onemore"
518
527
let &cursorline = 0
519
528
let &lazyredraw = 1
529
+ let &paste = 0
520
530
" We could have already saved the view from multiple_cursors#find
521
531
if ! self .start_from_find
522
532
let self .saved_winview = winsaveview ()
@@ -529,6 +539,7 @@ function! s:CursorManager.restore_user_settings() dict
529
539
let &virtualedit = self .saved_settings[' virtualedit' ]
530
540
let &cursorline = self .saved_settings[' cursorline' ]
531
541
let &lazyredraw = self .saved_settings[' lazyredraw' ]
542
+ let &paste = self .saved_settings[' paste' ]
532
543
endif
533
544
endfunction
534
545
@@ -742,7 +753,7 @@ function! s:feedkeys(keys)
742
753
endfunction
743
754
744
755
" Take the user input and apply it at every cursor
745
- function ! s: process_user_inut ()
756
+ function ! s: process_user_input ()
746
757
" Grr this is frustrating. In Insert mode, between the feedkey call and here,
747
758
" the current position could actually CHANGE for some odd reason. Forcing a
748
759
" position reset here
@@ -876,7 +887,7 @@ function! s:exit()
876
887
let exit = 1
877
888
endif
878
889
if exit
879
- call s: cm .reset (1 )
890
+ call s: cm .reset (1 , 1 )
880
891
return 1
881
892
endif
882
893
return 0
@@ -923,7 +934,7 @@ function! s:revert_highlight_fix()
923
934
if type (s: saved_line ) == 1
924
935
if s: from_mode == # ' i'
925
936
silent ! undojoin | call setline (' .' , s: saved_line )
926
- else
937
+ else
927
938
call setline (' .' , s: saved_line )
928
939
endif
929
940
endif
@@ -961,7 +972,7 @@ function! s:end_latency_measure()
961
972
silent ! echom " Starting latency debug at " .reltimestr (reltime ())
962
973
redir END
963
974
endif
964
-
975
+
965
976
if ! s: skip_latency_measure
966
977
exec ' redir >> ' .s: latency_debug_file
967
978
silent ! echom " Processing '" .s: char ." ' took " .string (str2float (reltimestr (reltime (s: start_time )))* 1000 ).' ms in ' .s: cm .size ().' cursors. mode = ' .s: from_mode
@@ -1000,7 +1011,7 @@ function! s:wait_for_user_input(mode)
1000
1011
if s: exit ()
1001
1012
return
1002
1013
endif
1003
-
1014
+
1004
1015
" If the key is a special key and we're in the right mode, handle it
1005
1016
if index (get (s: special_keys , s: from_mode , []), s: char ) != -1
1006
1017
call s: handle_special_key (s: char , s: from_mode )
0 commit comments