Skip to content

Commit 2daf0b3

Browse files
authored
feat(options)!: deprecate paste, remove pastetoggle (#22647)
we cannot remove 'paste'. It is very common in plugins and configs. 'pastetoggle' can and should be removed though, it's a total waste of everyone's time because it generates bug reports and doesn't work well, and is useless because bracketed-paste works better.
1 parent 673d2b5 commit 2daf0b3

18 files changed

+37
-325
lines changed

runtime/doc/autocmd.txt

-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ InsertCharPre When a character is typed in Insert mode,
704704
inserted literally.
705705

706706
Cannot change the text. |textlock|
707-
Not triggered when 'paste' is set.
708707
*InsertEnter*
709708
InsertEnter Just before starting Insert mode. Also for
710709
Replace mode and Virtual Replace mode. The

runtime/doc/change.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,6 @@ Note that when 'textwidth' is 0, Vim does no automatic formatting anyway (but
17251725
does insert comment leaders according to the 'comments' option). An exception
17261726
is when the 'a' flag is present. |auto-format|
17271727

1728-
Note that when 'paste' is on, Vim does no formatting at all.
1729-
17301728
Note that 'textwidth' can be non-zero even if Vim never performs auto-wrapping;
17311729
'textwidth' is still useful for formatting with "gq".
17321730

runtime/doc/deprecated.txt

+21
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,27 @@ OPTIONS
146146
- 'viewoptions' Flags "unix", "slash" are ignored and always enabled.
147147
- *'viminfo'* Deprecated alias to 'shada' option.
148148
- *'viminfofile'* Deprecated alias to 'shadafile' option.
149+
- *'paste'* *'nopaste'* This option is obsolete; |paste| is handled automatically.
150+
Enables "paste mode":
151+
- mappings in Insert mode and Command-line mode are
152+
disabled
153+
- abbreviations are disabled
154+
- 'autoindent' is reset
155+
- 'expandtab' is reset
156+
- 'formatoptions' is used like it is empty
157+
- 'revins' is reset
158+
- 'ruler' is reset
159+
- 'showmatch' is reset
160+
- 'smartindent' is reset
161+
- 'smarttab' is reset
162+
- 'softtabstop' is set to 0
163+
- 'textwidth' is set to 0
164+
- 'wrapmargin' is set to 0
165+
These options keep their value, but their effect is
166+
disabled:
167+
- 'cindent'
168+
- 'indentexpr'
169+
- 'lisp'
149170

150171
UI EXTENSIONS
151172
- *ui-wildmenu* Use |ui-cmdline| with |ui-popupmenu| instead. Enabled

runtime/doc/map.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ this (see |<>|). Example: >
695695
:map _ls :!ls -l %:S<CR>:echo "the end"<CR>
696696
697697
To avoid mapping of the characters you type in insert or Command-line mode,
698-
type a CTRL-V first. The mapping in Insert mode is disabled if the 'paste'
699-
option is on.
698+
type a CTRL-V first.
700699
*map-error*
701700
Note that when an error is encountered (that causes an error message or might
702701
cause a beep) the rest of the mapping is not executed. This is Vi-compatible.
@@ -1070,8 +1069,6 @@ Abbreviations are never recursive. You can use ":ab f f-o-o" without any
10701069
problem. But abbreviations can be mapped. {some versions of Vi support
10711070
recursive abbreviations, for no apparent reason}
10721071

1073-
Abbreviations are disabled if the 'paste' option is on.
1074-
10751072
*:abbreviate-local* *:abbreviate-<buffer>*
10761073
Just like mappings, abbreviations can be local to a buffer. This is mostly
10771074
used in a |filetype-plugin| file. Example for a C plugin file: >

runtime/doc/news.txt

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ The following changes may require adaptations in user config or plugins.
4545
- `printheader`
4646
- `printmbcharset`
4747

48+
'paste' option is now deprecated and 'pastetoggle' is removed. |paste| works
49+
automatically in GUI and terminal (TUI) Nvim. Just Paste It.™
50+
4851
• libiconv and intl are now required build dependencies.
4952

5053
• Unsaved changes are now preserved rather than discarded when |channel-stdio|

runtime/doc/options.txt

+2-95
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,6 @@ A jump table for the options with a short description can be found at |Q_op|.
676676
line.
677677
When 'smartindent' or 'cindent' is on the indent is changed in
678678
a different way.
679-
The 'autoindent' option is reset when the 'paste' option is set and
680-
restored when 'paste' is reset.
681679
{small difference from Vi: After the indent is deleted when typing
682680
<Esc> or <CR>, the cursor position when moving up or down is after the
683681
deleted indent; Vi puts the cursor somewhere in the deleted indent}.
@@ -1266,7 +1264,6 @@ A jump table for the options with a short description can be found at |Q_op|.
12661264
See |C-indenting|.
12671265
When you don't like the way 'cindent' works, try the 'smartindent'
12681266
option or 'indentexpr'.
1269-
This option is not used when 'paste' is set.
12701267

12711268
*'cinkeys'* *'cink'*
12721269
'cinkeys' 'cink' string (default "0{,0},0),0],:,0#,!^F,o,O,e")
@@ -2246,8 +2243,6 @@ A jump table for the options with a short description can be found at |Q_op|.
22462243
<Tab>. Spaces are used in indents with the '>' and '<' commands and
22472244
when 'autoindent' is on. To insert a real tab when 'expandtab' is
22482245
on, use CTRL-V<Tab>. See also |:retab| and |ins-expandtab|.
2249-
This option is reset when the 'paste' option is set and restored when
2250-
the 'paste' option is reset.
22512246

22522247
*'exrc'* *'ex'* *'noexrc'* *'noex'*
22532248
'exrc' 'ex' boolean (default off)
@@ -2749,9 +2744,8 @@ A jump table for the options with a short description can be found at |Q_op|.
27492744
'formatoptions' 'fo' string (default: "tcqj")
27502745
local to buffer
27512746
This is a sequence of letters which describes how automatic
2752-
formatting is to be done. See |fo-table|. When the 'paste' option is
2753-
on, no formatting is done (like 'formatoptions' is empty). Commas can
2754-
be inserted for readability.
2747+
formatting is to be done. See |fo-table|. Commas can be inserted for
2748+
readability.
27552749
To avoid problems with flags that are added in the future, use the
27562750
"+=" and "-=" feature of ":set" |add-option-flags|.
27572751

@@ -3392,7 +3386,6 @@ A jump table for the options with a short description can be found at |Q_op|.
33923386
When this option is not empty, it overrules the 'cindent' and
33933387
'smartindent' indenting. When 'lisp' is set, this option is
33943388
is only used when 'lispoptions' contains "expr:1".
3395-
When 'paste' is set this option is not used for indenting.
33963389
The expression is evaluated with |v:lnum| set to the line number for
33973390
which the indent is to be computed. The cursor is also in this line
33983391
when the expression is evaluated (but it may be moved around).
@@ -3761,7 +3754,6 @@ A jump table for the options with a short description can be found at |Q_op|.
37613754
The '-' character is included in keyword characters. Redefines the
37623755
"=" operator to use this same indentation algorithm rather than
37633756
calling an external program if 'equalprg' is empty.
3764-
This option is not used when 'paste' is set.
37653757

37663758
*'lispoptions'* *'lop'*
37673759
'lispoptions' 'lop' string (default "")
@@ -4474,77 +4466,6 @@ A jump table for the options with a short description can be found at |Q_op|.
44744466
Specifies the nroff macros that separate paragraphs. These are pairs
44754467
of two letters (see |object-motions|).
44764468

4477-
*'paste'* *'nopaste'*
4478-
'paste' boolean (default off)
4479-
global
4480-
This option is obsolete; |bracketed-paste-mode| is built-in.
4481-
4482-
Put Vim in Paste mode. This is useful if you want to cut or copy
4483-
some text from one window and paste it in Vim. This will avoid
4484-
unexpected effects.
4485-
Setting this option is useful when using Vim in a terminal, where Vim
4486-
cannot distinguish between typed text and pasted text. In the GUI, Vim
4487-
knows about pasting and will mostly do the right thing without 'paste'
4488-
being set. The same is true for a terminal where Vim handles the
4489-
mouse clicks itself.
4490-
This option is reset when starting the GUI. Thus if you set it in
4491-
your vimrc it will work in a terminal, but not in the GUI. Setting
4492-
'paste' in the GUI has side effects: e.g., the Paste toolbar button
4493-
will no longer work in Insert mode, because it uses a mapping.
4494-
When the 'paste' option is switched on (also when it was already on):
4495-
- mapping in Insert mode and Command-line mode is disabled
4496-
- abbreviations are disabled
4497-
- 'autoindent' is reset
4498-
- 'expandtab' is reset
4499-
- 'hkmap' is reset
4500-
- 'revins' is reset
4501-
- 'ruler' is reset
4502-
- 'showmatch' is reset
4503-
- 'smarttab' is reset
4504-
- 'softtabstop' is set to 0
4505-
- 'textwidth' is set to 0
4506-
- 'wrapmargin' is set to 0
4507-
- 'varsofttabstop' is made empty
4508-
These options keep their value, but their effect is disabled:
4509-
- 'cindent'
4510-
- 'formatoptions' is used like it is empty
4511-
- 'indentexpr'
4512-
- 'lisp'
4513-
- 'smartindent'
4514-
NOTE: When you start editing another file while the 'paste' option is
4515-
on, settings from the modelines or autocommands may change the
4516-
settings again, causing trouble when pasting text. You might want to
4517-
set the 'paste' option again.
4518-
When the 'paste' option is reset the mentioned options are restored to
4519-
the value before the moment 'paste' was switched from off to on.
4520-
Resetting 'paste' before ever setting it does not have any effect.
4521-
Since mapping doesn't work while 'paste' is active, you need to use
4522-
the 'pastetoggle' option to toggle the 'paste' option with some key.
4523-
4524-
*'pastetoggle'* *'pt'*
4525-
'pastetoggle' 'pt' string (default "")
4526-
global
4527-
When non-empty, specifies the key sequence that toggles the 'paste'
4528-
option. This is like specifying a mapping: >
4529-
:map {keys} :set invpaste<CR>
4530-
< Where {keys} is the value of 'pastetoggle'.
4531-
The difference is that it will work even when 'paste' is set.
4532-
'pastetoggle' works in Insert mode and Normal mode, but not in
4533-
Command-line mode.
4534-
Mappings are checked first, thus overrule 'pastetoggle'. However,
4535-
when 'paste' is on mappings are ignored in Insert mode, thus you can do
4536-
this: >
4537-
:map <F10> :set paste<CR>
4538-
:map <F11> :set nopaste<CR>
4539-
:imap <F10> <C-O>:set paste<CR>
4540-
:imap <F11> <nop>
4541-
:set pastetoggle=<F11>
4542-
< This will make <F10> start paste mode and <F11> stop paste mode.
4543-
Note that typing <F10> in paste mode inserts "<F10>", since in paste
4544-
mode everything is inserted literally, except the 'pastetoggle' key
4545-
sequence.
4546-
When the value has several bytes 'ttimeoutlen' applies.
4547-
45484469
*'pex'* *'patchexpr'*
45494470
'patchexpr' 'pex' string (default "")
45504471
global
@@ -4827,8 +4748,6 @@ A jump table for the options with a short description can be found at |Q_op|.
48274748
Inserting characters in Insert mode will work backwards. See "typing
48284749
backwards" |ins-reverse|. This option can be toggled with the CTRL-_
48294750
command in Insert mode, when 'allowrevins' is set.
4830-
This option is reset when 'paste' is set and restored when 'paste' is
4831-
reset.
48324751

48334752
*'rightleft'* *'rl'* *'norightleft'* *'norl'*
48344753
'rightleft' 'rl' boolean (default off)
@@ -4877,8 +4796,6 @@ A jump table for the options with a short description can be found at |Q_op|.
48774796
separated with a dash.
48784797
For an empty line "0-1" is shown.
48794798
For an empty buffer the line number will also be zero: "0,0-1".
4880-
This option is reset when 'paste' is set and restored when 'paste' is
4881-
reset.
48824799
If you don't want to see the ruler all the time but want to know where
48834800
you are, use "g CTRL-G" |g_CTRL-G|.
48844801

@@ -5610,8 +5527,6 @@ A jump table for the options with a short description can be found at |Q_op|.
56105527
show the match can be set with 'matchtime'.
56115528
A Beep is given if there is no match (no matter if the match can be
56125529
seen or not).
5613-
This option is reset when 'paste' is set and restored when 'paste' is
5614-
reset.
56155530
When the 'm' flag is not included in 'cpoptions', typing a character
56165531
will immediately move the cursor back to where it belongs.
56175532
See the "sm" field in 'guicursor' for setting the cursor shape and
@@ -5733,8 +5648,6 @@ A jump table for the options with a short description can be found at |Q_op|.
57335648
mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H.
57345649
When using the ">>" command, lines starting with '#' are not shifted
57355650
right.
5736-
This option is reset when 'paste' is set and restored when 'paste' is
5737-
reset.
57385651

57395652
*'smarttab'* *'sta'* *'nosmarttab'* *'nosta'*
57405653
'smarttab' 'sta' boolean (default on)
@@ -5749,8 +5662,6 @@ A jump table for the options with a short description can be found at |Q_op|.
57495662
What gets inserted (a <Tab> or spaces) depends on the 'expandtab'
57505663
option. Also see |ins-expandtab|. When 'expandtab' is not set, the
57515664
number of spaces is minimized by using <Tab>s.
5752-
This option is reset when 'paste' is set and restored when 'paste' is
5753-
reset.
57545665

57555666
*'softtabstop'* *'sts'*
57565667
'softtabstop' 'sts' number (default 0)
@@ -5763,8 +5674,6 @@ A jump table for the options with a short description can be found at |Q_op|.
57635674
commands like "x" still work on the actual characters.
57645675
When 'sts' is zero, this feature is off.
57655676
When 'sts' is negative, the value of 'shiftwidth' is used.
5766-
'softtabstop' is set to 0 when the 'paste' option is set and restored
5767-
when 'paste' is reset.
57685677
See also |ins-expandtab|. When 'expandtab' is not set, the number of
57695678
spaces is minimized by using <Tab>s.
57705679
The 'L' flag in 'cpoptions' changes how tabs are used when 'list' is
@@ -6579,8 +6488,6 @@ A jump table for the options with a short description can be found at |Q_op|.
65796488
Maximum width of text that is being inserted. A longer line will be
65806489
broken after white space to get this width. A zero value disables
65816490
this.
6582-
'textwidth' is set to 0 when the 'paste' option is set and restored
6583-
when 'paste' is reset.
65846491
When 'textwidth' is zero, 'wrapmargin' may be used. See also
65856492
'formatoptions' and |ins-textwidth|.
65866493
When 'formatexpr' is set it will be used to break the line.

runtime/doc/quickref.txt

-2
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,6 @@ Short explanation of each option: *option-list*
812812
'operatorfunc' 'opfunc' function to be called for |g@| operator
813813
'packpath' 'pp' list of directories used for packages
814814
'paragraphs' 'para' nroff macros that separate paragraphs
815-
'paste' allow pasting text
816-
'pastetoggle' 'pt' key code that causes 'paste' to toggle
817815
'patchexpr' 'pex' expression used to patch a file
818816
'patchmode' 'pm' keep the oldest version of a file
819817
'path' 'pa' list of directories searched with "gf" et.al.

runtime/doc/vim_diff.txt

+1
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ Options:
623623
'highlight' (Names of builtin |highlight-groups| cannot be changed.)
624624
*'hkmap'* *'hk'* use `set keymap=hebrew` instead.
625625
*'hkmapp'* *'hkp'* use `set keymap=hebrewp` instead.
626+
*'pastetoggle'* *'pt'*
626627

627628
*'imactivatefunc'* *'imaf'*
628629
*'imactivatekey'* *'imak'*

runtime/optwin.vim

+1-19
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ func <SID>Update(lnum, line, local, thiswin)
106106
else
107107
let name = substitute(a:line, '^ \tset \(no\)\=\([a-z]*\).*', '\2', "")
108108
endif
109-
if name == "pt" && &pt =~ "\x80"
110-
let val = <SID>PTvalue()
111-
else
112-
let val = escape(eval('&' . name), " \t\\\"|")
113-
endif
109+
let val = escape(eval('&' . name), " \t\\\"|")
114110
if a:local
115111
exe a:thiswin . "wincmd w"
116112
endif
@@ -211,14 +207,6 @@ func <SID>Header(text)
211207
let s:lnum = s:lnum + 1
212208
endfunc
213209

214-
" Get the value of 'pastetoggle'. It could be a special key.
215-
func <SID>PTvalue()
216-
redir @a
217-
silent set pt
218-
redir END
219-
return substitute(@a, '[^=]*=\(.*\)', '\1', "")
220-
endfunc
221-
222210
" Restore the previous value of 'cpoptions' here, it's used below.
223211
let &cpo = s:cpo_save
224212

@@ -232,12 +220,6 @@ call <SID>AddOption("cpoptions", gettext("list of flags to specify Vi compatibil
232220
call <SID>OptionG("cpo", &cpo)
233221
call <SID>AddOption("paste", gettext("paste mode, insert typed text literally"))
234222
call <SID>BinOptionG("paste", &paste)
235-
call <SID>AddOption("pastetoggle", gettext("key sequence to toggle paste mode"))
236-
if &pt =~ "\x80"
237-
call append("$", " \tset pt=" . <SID>PTvalue())
238-
else
239-
call <SID>OptionG("pt", &pt)
240-
endif
241223
call <SID>AddOption("runtimepath", gettext("list of directories used for runtime files and plugins"))
242224
call <SID>OptionG("rtp", &rtp)
243225
call <SID>AddOption("packpath", gettext("list of directories used for plugin packages"))

src/nvim/getchar.c

-52
Original file line numberDiff line numberDiff line change
@@ -2073,39 +2073,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
20732073
}
20742074
}
20752075

2076-
// Check for match with 'pastetoggle'
2077-
if (*p_pt != NUL && mp == NULL && (State & (MODE_INSERT | MODE_NORMAL))) {
2078-
bool match = typebuf_match_len((uint8_t *)p_pt, &mlen);
2079-
if (match) {
2080-
// write chars to script file(s)
2081-
if (mlen > typebuf.tb_maplen) {
2082-
gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen,
2083-
(size_t)(mlen - typebuf.tb_maplen));
2084-
}
2085-
2086-
del_typebuf(mlen, 0); // remove the chars
2087-
set_option_value_give_err("paste", !p_paste, NULL, 0);
2088-
if (!(State & MODE_INSERT)) {
2089-
msg_col = 0;
2090-
msg_row = Rows - 1;
2091-
msg_clr_eos(); // clear ruler
2092-
}
2093-
status_redraw_all();
2094-
redraw_statuslines();
2095-
showmode();
2096-
setcursor();
2097-
*keylenp = keylen;
2098-
return map_result_retry;
2099-
}
2100-
// Need more chars for partly match.
2101-
if (mlen == typebuf.tb_len) {
2102-
keylen = KEYLEN_PART_KEY;
2103-
} else if (max_mlen < mlen) {
2104-
// no match, may have to check for termcode at next character
2105-
max_mlen = mlen + 1;
2106-
}
2107-
}
2108-
21092076
if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP) {
21102077
// When no matching mapping found or found a non-matching mapping that
21112078
// matches at least what the matching mapping matched:
@@ -2116,13 +2083,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
21162083
|| (typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER && typebuf.tb_len < 4))) {
21172084
// Incomplete modifier sequence: cannot decide whether to simplify yet.
21182085
keylen = KEYLEN_PART_KEY;
2119-
} else if (keylen == KEYLEN_PART_KEY && !*timedout) {
2120-
// If 'pastetoggle' matched partially, don't simplify.
2121-
// When the last characters were not typed, don't wait for a typed character to
2122-
// complete 'pastetoggle'.
2123-
if (typebuf.tb_len == typebuf.tb_maplen) {
2124-
keylen = 0;
2125-
}
21262086
} else {
21272087
// Try to include the modifier into the key.
21282088
keylen = check_simplify_modifier(max_mlen + 1);
@@ -2923,18 +2883,6 @@ int fix_input_buffer(uint8_t *buf, int len)
29232883
return len;
29242884
}
29252885

2926-
static bool typebuf_match_len(const uint8_t *str, int *mlen)
2927-
{
2928-
int i;
2929-
for (i = 0; i < typebuf.tb_len && str[i]; i++) {
2930-
if (str[i] != typebuf.tb_buf[typebuf.tb_off + i]) {
2931-
break;
2932-
}
2933-
}
2934-
*mlen = i;
2935-
return str[i] == NUL; // matched the whole string
2936-
}
2937-
29382886
/// Get command argument for <Cmd> key
29392887
char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
29402888
{

0 commit comments

Comments
 (0)