xref: /openbsd-src/usr.bin/vi/FAQ (revision cb0f08391f08bfdd60c863afeed394ea193ebe45)
132ceefb1Sdownsj@(#)FAQ	8.13 (Berkeley) 10/14/96
245f2ab88Sderaadt
3a513d41bSmichaelsQ: How can I get vi to display my character set?
4a513d41bSmichaelsA: Vi uses the C library routine isprint(3) to determine if a character
545f2ab88Sderaadt   is printable, or should be displayed as an octal or hexadecimal value
6a513d41bSmichaels   on the screen.  Generally, if vi is displaying printable characters
745f2ab88Sderaadt   in octal/hexadecimal forms, your environment is not configured correctly.
845f2ab88Sderaadt   Try looking at the man pages that allow you to configure your locale.
945f2ab88Sderaadt   For example, to configure an ISO 8859-1 locale under Solaris using csh,
1045f2ab88Sderaadt   you would do:
1145f2ab88Sderaadt
1245f2ab88Sderaadt	setenv LANG C
1345f2ab88Sderaadt	setenv LC_CTYPE iso_8859_1
1445f2ab88Sderaadt
1545f2ab88Sderaadt   Other LC_CTYPE systems/values that I'm told work:
1645f2ab88Sderaadt
1745f2ab88Sderaadt   System	Value
1845f2ab88Sderaadt   ======	=====
1945f2ab88Sderaadt   FreeBSD	lt_LN.ISO_8859-1
2045f2ab88Sderaadt   HP-UX  9.X	american.iso88591
2145f2ab88Sderaadt   HP-UX 10.X	en_US.iso88591
2245f2ab88Sderaadt   SunOS  4.X	iso_8859_1
2345f2ab88Sderaadt   SunOS  5.X	iso_8859_1
2445f2ab88Sderaadt
2524e643d6Smichaels   If there's no other solution, you can use the print and noprint edit
2624e643d6Smichaels   options of vi to specify that a specific character is printable or not
2724e643d6Smichaels   printable.
2824e643d6Smichaels
2945f2ab88SderaadtQ: My map won't work!
3045f2ab88SderaadtA: One thing that you should immediately check if a vi map doesn't work
3145f2ab88Sderaadt   is if depends on the final cursor position after a P or p command.
3245f2ab88Sderaadt   Historic vi's were inconsistent as to the final position of the cursor,
3345f2ab88Sderaadt   and, to make matter worse, the final cursor position also depended on
34a513d41bSmichaels   whether the put text came from a named or unnamed buffer!  Vi follows
3545f2ab88Sderaadt   the POSIX 1003.2 standard on this one, and makes this consistent, always
3645f2ab88Sderaadt   placing the cursor on the first character.
3745f2ab88Sderaadt
3845f2ab88SderaadtQ: I'm using ksh or csh as my vi edit option shell value, and file
3945f2ab88Sderaadt   expansions don't work right!
4045f2ab88SderaadtA: The problem may be in your ksh or csh startup files, e.g., .cshrc.  Vi
4145f2ab88Sderaadt   executes the shell to do name expansion, and the shell generally reads
4245f2ab88Sderaadt   its startup files.  If the startup files are not correctly configured
4345f2ab88Sderaadt   for non-interactive use, e.g., they always echo a prompt to the screen,
4445f2ab88Sderaadt   vi will be unable to parse the output and things will not work
4545f2ab88Sderaadt   correctly.
4645f2ab88Sderaadt
4745f2ab88SderaadtQ: How does the iclower edit option differ from the ignorecase (i.e. ic)
4845f2ab88Sderaadt   edit option?
4945f2ab88SderaadtA: The difference is that the ignorecase edit option always ignores the
5045f2ab88Sderaadt   case of letters in the Regular Expression (RE), and the iclower edit
5145f2ab88Sderaadt   option only ignores the case if there are no upper-case letters in the
5245f2ab88Sderaadt   RE.  If any upper-case letters appear in the Regular Expression, then
5345f2ab88Sderaadt   it will be treated case-sensitively, as if the ignorecase edit option
5445f2ab88Sderaadt   was not set.
5545f2ab88Sderaadt
56a513d41bSmichaelsQ: When I edit binary files, vi appends a <newline> to the last line!
5745f2ab88SderaadtA: This is historic practice for vi, and further, it's required by the
5845f2ab88Sderaadt   POSIX 1003.2 standard.  My intent is to provide a command line and/or
5945f2ab88Sderaadt   edit option to turn this behavior off when I switch to version 2.0 of
6045f2ab88Sderaadt   the Berkeley DB package.
6145f2ab88Sderaadt
6245f2ab88SderaadtQ: My cursor keys don't work when I'm in text input mode!
6345f2ab88SderaadtA: A common problem over slow links is that the set of characters sent by
6445f2ab88Sderaadt   the cursor keys don't arrive close enough together for vi to understand
6545f2ab88Sderaadt   that they are a single keystroke, and not separate keystrokes.  Try
6645f2ab88Sderaadt   increasing the value of the escapetime edit option, which will cause
6745f2ab88Sderaadt   vi to wait longer before deciding that the <escape> character that
6845f2ab88Sderaadt   starts cursor key sequences doesn't have any characters following it.
6945f2ab88Sderaadt
70a513d41bSmichaelsQ: When I edit some files, vi seems to hang forever, and I have to kill it.
71a513d41bSmichaelsA: Vi uses flock(2) and fcntl(2) to do file locking.  When it attempts to
7245f2ab88Sderaadt   acquired a lock for a file on an NFS mounted filesystem, it can hang
7345f2ab88Sderaadt   for a very long (perhaps infinite) period of time.  Turning off the
74a513d41bSmichaels   "lock" edit option will keep vi from attempting to acquire any locks
7545f2ab88Sderaadt   on the files you edit.
76a513d41bSmichaels
77a513d41bSmichaelsQ: When I compile vi I get lots of warnings about pointer assignments
78a513d41bSmichaels   being incompatible!
79a513d41bSmichaelsA: Vi is partially written to support wide characters.  When this code
80a513d41bSmichaels   interfaces with the code that doesn't yet support wide characters,
81a513d41bSmichaels   the pointer types clash.  This will hopefully be fixed in the near
82a513d41bSmichaels   future, but I've been saying that for awhile, now.
83a513d41bSmichaels
84a513d41bSmichaelsQ: I get jumpy scrolling behavior in the screen!
85a513d41bSmichaelsA: This is almost certainly a problem with the system's terminfo or
86a513d41bSmichaels   termcap information for your terminal.  If the terminfo/termcap entry
87a513d41bSmichaels   doesn't have the settable scrolling region capabilities, or the more
88a513d41bSmichaels   powerful scrolling commands, these behaviors can result.  Historic
89a513d41bSmichaels   implementations of vi, and some of the vi clones, don't suffer from
90a513d41bSmichaels   this problem because they wrote their own screen support instead of
91a513d41bSmichaels   using the curses library.
92a513d41bSmichaels
93a513d41bSmichaels   The solution is to find a good terminfo or termcap entry for your
94a513d41bSmichaels   terminal, which will fix the problem for all of the applications on
95a513d41bSmichaels   your system, not just vi.  Eric Raymond maintains the freely
96a513d41bSmichaels   redistributable termcap/terminfo entries.  They can be downloaded
97a513d41bSmichaels   from http://www.ccil.org/~esr/ncurses.html, or you can contact him
98a513d41bSmichaels   at esr@snark.thyrsus.com.
99a513d41bSmichaels
100a513d41bSmichaelsQ: The entire screen repaints on every keystroke!
101a513d41bSmichaelsA: Your system's curses implementation is broken.  You should use the
10224e643d6Smichaels   curses implementation provided with vi or a curses replacement such
10324e643d6Smichaels   as ncurses.  Eric Raymond is one of the maintainers of the freely
104a513d41bSmichaels   redistributable ncurses package.  You can download ncurses from
105a513d41bSmichaels   http://www.ccil.org/~esr/ncurses.html, or you can contact him at
106a513d41bSmichaels   esr@snark.thyrsus.com.
107a513d41bSmichaels
108a513d41bSmichaelsQ: When I use vi on a Sun console (terminal type sun-34) the screen
109a513d41bSmichaels   is occasionally trashed, usually when exiting vi!
110a513d41bSmichaelsA: The Sun console can't handle the 'al' capability of the termcap
111a513d41bSmichaels   entry (the il1 capability of terminfo entries).  If you delete that
112a513d41bSmichaels   entry from your terminfo/termcap information everything should work
113a513d41bSmichaels   correctly.
114a513d41bSmichaels
115a513d41bSmichaelsQ: I don't have a version of ctags (or I have ctags, but it doesn't tag
116a513d41bSmichaels   nearly enough things)!
117a513d41bSmichaelsA: There's a version of ctags available on the 4.4BSD-Lite distributions,
118*cb0f0839Smillert   as well as the OpenBSD, FreeBSD, NetBSD, Linux and GNU distributions.
119*cb0f0839Smillert   Or, you might want to try Exuberant Ctags:
120a513d41bSmichaels
121a513d41bSmichaels	Title:		Exuberant Ctags
122a513d41bSmichaels	Version:	1.3
123a513d41bSmichaels	Entered-date:	16JUN96
124a513d41bSmichaels	Description:
125a513d41bSmichaels	    A better ctags which generates tags for all possible tag types:
126a513d41bSmichaels	    macro definitions, enumerated values (values inside enum{...}),
127a513d41bSmichaels	    function and method definitions, enum/struct/union tags, external
128a513d41bSmichaels	    function prototypes (optional), typedefs, and variable
129a513d41bSmichaels	    declarations. It is far less easily fooled by code containing #if
130a513d41bSmichaels	    preprocessor conditional constructs, using a conditional path
131a513d41bSmichaels	    selection algorithm to resolve complicated choices, and a
132a513d41bSmichaels	    fall-back algorithm when this one fails. Can also be used to print
133a513d41bSmichaels	    out a list of selected objects found in source files.
134a513d41bSmichaels	Keywords:	ctags, tags, exuberant
135a513d41bSmichaels	Author:		darren@sirsi.com (Darren Hiebert)
136a513d41bSmichaels			darren@hiwaay.net (Darren Hiebert)
137a513d41bSmichaels	Maintained-by:	darren@sirsi.com (Darren Hiebert)
138a513d41bSmichaels			darren@hiwaay.net (Darren Hiebert)
139a513d41bSmichaels	Primary-site:	sunsite.unc.edu /pub/Linux/devel/lang/c
140a513d41bSmichaels			27kB ctags-1.3.tar.gz
141a513d41bSmichaels	Alternate-site:	ftp.halcyon.com /local/gvr
142a513d41bSmichaels			27kB ctags-1.3.tar.gz
143a513d41bSmichaels	Original-site:
144a513d41bSmichaels	Platforms:	UNIX, MSDOS, WindowsNT, Windows95, OS/2, Amiga
145a513d41bSmichaels	Copying-policy:	Public domain
146a513d41bSmichaels
147a513d41bSmichaelsQ: When I update a file I already have open, and use :e to reread it, I
148a513d41bSmichaels   get nul's for the rest of the file!
149a513d41bSmichaelsA: Your system's implementation of mmap(2) has a bug; you will have to
150a513d41bSmichaels   exit vi and re-execute it.
15132ceefb1Sdownsj
15232ceefb1SdownsjQ: Where can I get cscope?
15332ceefb1SdownsjA: Cscope is available on UNIXWare System V Release 4.0 variants such as
15432ceefb1Sdownsj   Sun Solaris 2.x (/opt/SUNWspro/bin) and UNIXWare System V Release 4.1.
15532ceefb1Sdownsj
15632ceefb1Sdownsj   You can buy version 13.3 source with an unrestricted license for $400
15732ceefb1Sdownsj   from AT&T Software Solutions by calling +1-800-462-8146.  Binary
15832ceefb1Sdownsj   redistribution of cscope is an additional $1500, one-time flat fee.
15932ceefb1Sdownsj
16032ceefb1Sdownsj   For more information, see http://www.unipress.com/att/new/cscope.html.
161