LoginSignup
38

More than 5 years have passed since last update.

vimで貼付け時に自動でpasteモードにする

Posted at

vimでOSのクリップボードから貼り付けたいときは,
一度set pasteでペーストモードにしてから貼り付ける.

これが,結構面倒くさいんだけど以下のスクリプトを使うと簡単に貼り付けができるようになる.

ノーマルモードでペーストを行うと自動でペーストモードになって,
クリップボードの中身を貼り付けてくれる.

オススメです.

if &term =~ "xterm"
    let &t_ti .= "\e[?2004h"
    let &t_te .= "\e[?2004l"
    let &pastetoggle = "\e[201~"

    function XTermPasteBegin(ret)
        set paste
        return a:ret
    endfunction

    noremap <special> <expr> <Esc>[200~ XTermPasteBegin("0i")
    inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
    cnoremap <special> <Esc>[200~ <nop>
    cnoremap <special> <Esc>[201~ <nop>
endif

参考文献

  • あったけどロストしてしまいました...

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38