<s>
)	O
,	O
is	O
a	O
mode	B-General_Concept
of	O
some	O
terminal	B-Application
emulators	I-Application
which	O
allows	O
programs	O
running	O
in	O
the	O
terminal	O
to	O
treat	O
pasted	O
text	O
differently	O
from	O
text	O
typed	O
normally	O
.	O
</s>
<s>
The	O
bracketed	B-General_Concept
paste	I-General_Concept
feature	O
was	O
introduced	O
by	O
xterm	B-Language
in	O
2002	O
,	O
as	O
a	O
user-contributed	O
change	O
to	O
improve	O
interaction	O
with	O
Emacs	B-Application
.	O
</s>
<s>
Later	O
,	O
in	O
2005	O
,	O
another	O
user	O
documented	O
this	O
as	O
part	O
of	O
another	O
select/paste	O
feature	O
for	O
the	O
JOE	B-Device
editor	I-Device
.	O
</s>
<s>
Over	O
the	O
course	O
of	O
several	O
years	O
,	O
other	O
developers	O
adapted	O
the	O
feature	O
for	O
terminal	B-Application
emulators	I-Application
and	O
editors	O
which	O
work	O
with	O
this	O
feature	O
.	O
</s>
<s>
Bracketed	B-General_Concept
paste	I-General_Concept
is	O
used	O
to	O
resolve	O
the	O
following	O
issue	O
,	O
commonly	O
encountered	O
when	O
editing	O
code	B-Application
in	O
a	O
terminal	O
text	B-Application
editor	I-Application
(	O
such	O
as	O
Vim	B-Application
or	O
Emacs	B-Application
)	O
.	O
</s>
<s>
These	O
text	B-Application
editors	I-Application
often	O
include	O
autoindent	O
functionality	O
,	O
which	O
causes	O
indentation	O
to	O
be	O
added	O
automatically	O
when	O
the	O
user	O
presses	O
the	O
enter	B-Device
key	I-Device
at	O
the	O
end	O
of	O
a	O
line	O
.	O
</s>
<s>
For	O
example	O
,	O
suppose	O
we	O
are	O
editing	O
the	O
following	O
code	B-Application
block	O
in	O
a	O
text	B-Application
editor	I-Application
,	O
with	O
the	O
cursor	O
position	O
marked	O
by	O
the	O
|	O
character.If	O
the	O
user	O
presses	O
enter	O
,	O
text	B-Application
editors	I-Application
will	O
often	O
advance	O
the	O
cursor	O
to	O
the	O
location	O
marked	O
in	O
the	O
next	O
code	B-Application
block.This	O
can	O
have	O
unintended	O
consequences	O
when	O
pasting	O
code	B-Application
which	O
is	O
already	O
formatted	O
.	O
</s>
<s>
For	O
example	O
,	O
suppose	O
the	O
user	O
intends	O
to	O
copy	O
the	O
following	O
block	O
of	O
code	B-Application
into	O
a	O
file.In	O
a	O
typical	O
workflow	O
,	O
the	O
user	O
starts	O
by	O
selecting	O
the	O
block	O
of	O
code	B-Application
and	O
copying	O
it	O
to	O
their	O
system	O
clipboard	O
.	O
</s>
<s>
The	O
terminal	B-Application
emulator	I-Application
then	O
send	O
the	O
characters	O
from	O
the	O
clipboard	O
to	O
the	O
text	B-Application
editor	I-Application
,	O
and	O
the	O
text	B-Application
editor	I-Application
may	O
not	O
be	O
able	O
to	O
differentiate	O
between	O
,	O
for	O
example	O
,	O
a	O
d	O
character	O
that	O
came	O
from	O
the	O
clipboard	O
and	O
one	O
which	O
came	O
from	O
the	O
user	O
pressing	O
the	O
D	O
key	O
on	O
her	O
keyboard	O
.	O
</s>
<s>
The	O
newlines	O
in	O
the	O
code	B-Application
block	O
are	O
treated	O
the	O
same	O
way	O
as	O
would	O
be	O
presses	O
of	O
the	O
enter	B-Device
key	I-Device
by	O
the	O
user	O
.	O
</s>
<s>
So	O
,	O
when	O
the	O
newline	O
at	O
the	O
end	O
of	O
the	O
first	O
line	O
is	O
sent	O
to	O
the	O
text	B-Application
editor	I-Application
,	O
if	O
autoindent	O
is	O
enabled	O
,	O
the	O
text	B-Application
editor	I-Application
will	O
insert	O
an	O
indent	O
(	O
several	O
spaces	O
or	O
a	O
tab	O
character	O
)	O
.	O
</s>
<s>
Next	O
,	O
the	O
terminal	B-Application
emulator	I-Application
will	O
transmit	O
the	O
space	O
characters	O
corresponding	O
to	O
the	O
spaces	O
at	O
the	O
beginning	O
of	O
the	O
second	O
line	O
of	O
the	O
block	O
of	O
code	B-Application
on	O
the	O
clipboard	O
,	O
resulting	O
in	O
double-indentation	O
.	O
</s>
<s>
Terminal	B-Application
emulators	I-Application
(	O
such	O
as	O
xterm	B-Language
and	O
iTerm2	B-Language
)	O
allow	O
programs	O
to	O
configure	O
the	O
terminal	B-Application
emulators	I-Application
 '	O
behavior	O
via	O
escape	O
codes	O
,	O
or	O
control	O
sequences	O
.	O
</s>
<s>
The	O
usual	O
way	O
this	O
is	O
done	O
is	O
that	O
a	O
user	O
program	O
prints	O
a	O
control	O
sequence	O
to	O
standard	B-Operating_System
out	I-Operating_System
,	O
and	O
the	O
terminal	B-Application
emulator	I-Application
reads	O
standard	B-Operating_System
out	I-Operating_System
,	O
notices	O
the	O
control	O
sequence	O
,	O
and	O
reacts	O
as	O
appropriate	O
.	O
</s>
<s>
In	O
particular	O
,	O
terminal	B-Application
emulators	I-Application
may	O
provide	O
control	O
sequences	O
that	O
turn	O
bracketed-paste	B-General_Concept
on	O
and	O
off	O
.	O
</s>
<s>
A	O
text	B-Application
editor	I-Application
may	O
send	O
the	O
control	O
sequence	O
to	O
turn	O
on	O
bracketed-paste	B-General_Concept
at	O
startup	O
,	O
or	O
in	O
response	O
to	O
a	O
user	O
command	O
.	O
</s>
<s>
Thereafter	O
,	O
characters	O
typed	O
by	O
the	O
user	O
normally	O
will	O
be	O
forwarded	O
to	O
the	O
text	B-Application
editor	I-Application
by	O
the	O
terminal	B-Application
emulator	I-Application
normally	O
.	O
</s>
<s>
However	O
,	O
if	O
the	O
user	O
issues	O
a	O
paste	O
command	O
in	O
the	O
terminal	B-Application
emulator	I-Application
,	O
the	O
terminal	B-Application
emulator	I-Application
will	O
insert	O
special	O
control	O
sequences	O
at	O
the	O
beginning	O
and	O
end	O
of	O
the	O
pasted	O
text	O
–	O
it	O
will	O
bracket	O
the	O
pasted	O
contents	O
–	O
enabling	O
the	O
text	B-Application
editor	I-Application
to	O
treat	O
that	O
input	O
differently	O
(	O
for	O
example	O
,	O
to	O
turn	O
autoindentation	O
off	O
temporarily	O
)	O
.	O
</s>
<s>
Each	O
implementation	O
uses	O
the	O
control	O
sequences	O
documented	O
in	O
xterm	B-Language
's	O
control	O
sequences	O
:	O
</s>
