function! s:vscodePrepareMultipleCursors(append, skipEmpty) let m = mode() if m ==# 'V' || m ==# "\" let b:notifyMultipleCursors = 1 let b:multipleCursorsVisualMode = m let b:multipleCursorsAppend = a:append let b:multipleCursorsSkipEmpty = a:skipEmpty " We need to start insert, then spawn cursors otherwise they'll be destroyed " using feedkeys() here because :startinsert is being delayed call feedkeys("\i", 'n') endif endfunction function! s:vscodeNotifyMultipleCursors() if exists('b:notifyMultipleCursors') && b:notifyMultipleCursors let b:notifyMultipleCursors = 0 call VSCodeExtensionNotify('visual-edit', b:multipleCursorsAppend, b:multipleCursorsVisualMode, line("'<"), line("'>"), col("'>"), b:multipleCursorsSkipEmpty) endif endfunction augroup MultipleCursors autocmd! autocmd InsertEnter * call vscodeNotifyMultipleCursors() augroup END " Multiple cursors support for visual line/block modes xnoremap ma call vscodePrepareMultipleCursors(1, 1) xnoremap mi call vscodePrepareMultipleCursors(0, 1) xnoremap mA call vscodePrepareMultipleCursors(1, 0) xnoremap mI call vscodePrepareMultipleCursors(0, 0)