0

when I tried to paste code

for(int i = 1; i <= N; i++) if(ord[i] == -1) dfs(i, 0, i);

from clipboard in vim(of course in insert mode), it became

for(int i = 1); i <= N; i++) if(ord[i] == -1) dfs(i, 0, i);

Is it because I'm using some plugins about brackets?

my .vimrc is

colorscheme solarflare
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'Auto-Pairs'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'vim-multiple-cursors'
Plugin 'surround.vim'
Plugin 'LucHermitte/lh-vim-lib'
Plugin 'LucHermitte/lh-brackets'
call vundle#end()
filetype plugin indent on " Put your non-Plugin stuff after this line
syntax enable
set nu
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
let g:syntastic_cpp_compiler_options = ' -std=c++11'
set t_ut=
set clipboard=unnamedplus
let c_no_curly_error=1

Is there any problem? Please tell me why and then what should i do? Thank you.

3
  • If I may, using autopair+surround and lh-brackets doesn't make much sense. They are alternative plugins that do the same thing (differently of course). Oct 2, 2017 at 12:38
  • Were you using pastemode when this happened? Pastemode solves a lot of problems like this. (help paste)
    – D. Ben Knoble
    Oct 2, 2017 at 19:13
  • Paste from register using "+p or <C-r>+ in insert mode.
    – Hauleth
    Oct 2, 2017 at 19:59

1 Answer 1

5

The issue comes from the LucHermitte/lh-brackets plugin. The issue is the plugin sees an open parenthesis and decides it wants you to add the close parenthesis before the ; and so tries to be helpful by adding it in for you.

... and then what should I do?

Is this your own .vimrc or is this from someone else?

If it's your own chances are you probably didn't spend much time reading through the plugin documentations to understand how to use them properly (I did the same too! I know it's hard as a beginner but you'll become better at it if you dive in head first and learn from the get go). If this is the case take the time to read through the documentation and the issues to see if you can find a mention of how to fix your issue. If there's no mention of how to prevent it happening and no issues opened on github then open an issue and explain whats happening. This way LucHermitte will be able to tell you if this is a bug or if you've missed something in the documentation. If this doesn't work out for you, find another plugin, theres plenty out there that will do the job (but understand them, or at least the basics, before you add them)!

If this is someone elses .vimrc then make your own! It's a lot more fun to customise your own and then you'll know what might be causing issues if when your .vimrc gives you more problems.

As a final note, it really isn't hard to debug your .vimrc yourself, and it is definitely recommended and encouraged you try debug it yourself before asking on a SE site as it shows you've put some time into solving your problem yourself! Have a look through this answer as a guide on how to do so in future :)

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.