Subject: is vi(1)'s autoindent the right default behaviour?
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Igor Sobrado <igor@string1.ciencias.uniovi.es>
List: tech-userlevel
Date: 05/08/2005 12:24:20
Perhaps it is an acceptable behaviour, don't know. But I want to note
that when EXINIT is set to `set autoindent' copying and pasting between
xterms do not work as most users expect. I will use the next sample
text to outline the problem, related with the autoindent feature on vi(1):
(first set: four spaces before each text line)
1 2 3 4 5 6 7 7
0 0 0 0 0 0 0 2
---------+---------+---------+---------+---------+---------+---------+--
line number 1 - set 1
line number 2 - set 1
line number 3 - set 1
line number 4 - set 1
(second set: a <tab> before each text line)
1 2 3 4 5 6 7 7
0 0 0 0 0 0 0 2
---------+---------+---------+---------+---------+---------+---------+--
line number 1 - set 2
line number 2 - set 2
line number 3 - set 2
line number 4 - set 2
When EXINIT is set to `set autoindent', lines pasted in vi(1) are
automatically indented --- as a consequence space before the first
nonblank character on each line in the source text is added to
the previous indentation:
For the first set four additional spaces are added to each line (and
replaced with <tabs> if possible):
line number 1 - set 1
line number 2 - set 1
line number 3 - set 1
line number 4 - set 1
For the second set a <tab> is added to each line (eight spaces to the
first one):
line number 1 - set 2
line number 2 - set 2
line number 3 - set 2
line number 4 - set 2
When EXINIT is NOT set to `set autoindent' copying and pasting to vi(1)
works as most users want:
For the first set:
line number 1 - set 1
line number 2 - set 1
line number 3 - set 1
line number 4 - set 1
For the second set:
line number 1 - set 2
line number 2 - set 2
line number 3 - set 2
line number 4 - set 2
ok... <tabs> are translated to spaces on all lines but the source layout
is preserved. This translation is an xterm(1) related issue.
I want to discuss this behaviour on the mailing list. If this behaviour
is considered wrong, I will be glad to open a PR. I suggest these patches:
For csh users:
--- dot.cshrc 2005-05-08 12:05:59.000000000 +0200
+++ dot.cshrc.proposed 2005-05-08 12:07:08.000000000 +0200
@@ -18,7 +18,6 @@
setenv EDITOR vi
setenv VISUAL ${EDITOR}
-setenv EXINIT 'set autoindent'
setenv PAGER more
set path = (~/bin /bin /sbin /usr/{bin,sbin,X11R6/bin,pkg/{,s}bin,games} \
For Bourne shell users:
--- dot.profile 2005-05-08 12:06:02.000000000 +0200
+++ dot.profile.proposed 2005-05-08 12:07:23.000000000 +0200
@@ -15,7 +15,5 @@
EDITOR=vi
export EDITOR
-EXINIT='set autoindent'
-export EXINIT
PAGER=more
export PAGER
(both patches must be applied to files in src/etc/skel)
Cheers,
Igor.