开发者

Which .vimrc setting causes this weird copy-paste behaviour?

I recently copy-pasted a bunch of .vimrc settings from somewhere, and now I have this weird behaviour on text copy paste:

  1. Which .vimrc setting causes this weird copy-paste behaviour?

  2. Ctrl + C开发者_StackOverflow社区

  3. Shift + Insert

  4. Which .vimrc setting causes this weird copy-paste behaviour?

I thought it would be autoindent but it is not.

What should I remove from my .vimrc to stop this behaviour and enable normal copy paste?


The fault is somewhere in this part of my .vimrc :

command -range=% -nargs=* Tidy <line1>,<line2>!
    \perltidy -your -preferred -default -options <args>

vmap <tab> >gv 
vmap <s-tab> <gv

nmap <tab> I<tab><esc>
nmap <s-tab> ^i<bs><esc>

let perl_include_pod   = 1
let perl_extended_vars = 1
let perl_sync_dist     = 250

filetype off
set nocompatible
set modelines=0

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set ic
set ai
set nu

command -range Cm <line1>,<line2>s/^/#/
command -range Uc <line1>,<line2>s/^#//

set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2

let mapleader = ","
nnoremap <leader>1 yypVr-
nnoremap <leader>2 yypVr=

set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch

set wrap
set textwidth=79
set formatoptions=qrn1
nnoremap j gj
nnoremap k gk

nnoremap ; :
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
nnoremap <leader>w <C-w>v<C-w>l
syntax on
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp

set noerrorbells


before pasting, to avoid such behavior you should :set paste before pasting and :set nopaste after.

This is because the paste emulate the typing. It's even worst when you paste indented text.

This doesn't surface if you use the vim's yanking (internal "copy-paste").


The r in set formatoptions=qrn1 is supposed to cause this kind of behaviour. But paste mode is more suited to, well pasting. Enter paste mode by giving set paste and leave it by giving set nopaste. help paste has information.


Actually you don't even have do think about :set paste, as you can use the command <C-r><C-o>+ in insert mode to do a raw paste from the clipboard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜