From 78b4b4be41d987f2ee23d10d7318c12ff1adfa77 Mon Sep 17 00:00:00 2001 From: kana Date: Tue, 11 Mar 2008 18:38:10 +0900 Subject: [PATCH] Auto 'paste' by experimental conditions --- runtime/doc/hacks.txt | 13 +++++++++++++ src/getchar.c | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/runtime/doc/hacks.txt b/runtime/doc/hacks.txt index 626a69d..18fa795 100644 --- a/runtime/doc/hacks.txt +++ b/runtime/doc/hacks.txt @@ -7,6 +7,19 @@ All changes are licensed under the same terms of Vim. See |license|. ============================================================================== INDEX OF HACKS *hacks-index* +Auto setting 'paste' *hacks-autopaste* + When input text seems to be pasted, set 'paste' automatically. + The conditions are: + 1) the length of input text is greater than 10 bytes, and + 2) input text contains at least 1 carriage return ("\r"). + + Note that this hack doesn't unset 'paste' automatically. So you have + to add the following setting in your |vimrc|: +> + autocmd InsertLeave * set nopaste +< + Reference: http://d.hatena.ne.jp/parasporospa/20071129/p1 + diff --git a/src/getchar.c b/src/getchar.c index d1c70c9..860b92c 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2945,6 +2945,10 @@ inchar(buf, maxlen, wait_time, tb_change_cnt) if (typebuf_changed(tb_change_cnt)) return 0; + if (10 < len && memchr(buf, '\r', len)) { + do_cmdline_cmd("set paste"); + showmode(); + } return fix_input_buffer(buf, len, script_char >= 0); } -- 2.11.4.GIT