vimvim-pluginmultiple-cursor

Disable auto-pair when using multiple cursors in vim


I am using the vim plugins vim-multiple-cursors and auto-pairs. If I am editing a block of text for example:

one
two
three
four

If I highlight the block with the command

vip <ctrl-n> I "

this will create two parenthesis in the front because auto-pairs is active.

""one
""two
""three
""four 

Is there a way to have auto-pairs turn off automatically when you are using vim-multiple cursors?

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

""""""""" PLUGIN LIST STARTS HERE """"""""""""""""""""
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/syntastic'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-surround'
Plugin 'ervandew/supertab'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-repeat'
Plugin 'scrooloose/nerdtree'
""""""""" PLUGIN LIST END HERE """"""""""""""""""""
call vundle#end()            " required
filetype plugin indent on    " requiredntax on

syntax on
set tabstop=4
set number
set smartindent
set shiftwidth=4
set mouse=a
set backspace=indent,eol,start

let &t_SI.="\e[5 q"
let &t_SR.="\e[4 q"
let &t_EI.="\e[1 q"

let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
map <F5> :NERDTreeToggle<CR>

let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'

Solution

  • Autopairs has a function called AutoPairsToggle() which you need to call before entering and after leaving multiple cursors mode.

    vim-multiple-cursors provides you with a way to resolve plugin interactions: define a pre and post hook:

    function! Multiple_cursors_before()
      call AutoPairsToggle()
    endfun
    
    function! Multiple_cursors_after()
      call AutoPairsToggle()
    endfun
    

    Put these in your .vimrc and the problem should no longer occur.