mirror of https://github.com/tLDP/LDP
6650 lines
210 KiB
XML
6650 lines
210 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
** The syntax of DOCTYPE is described in
|
|
http://www.freebsd.cz/doc/en_US.ISO8859-1/books/fdp-primer/sgml-primer-doctype-declaration.html
|
|
** and described at http://xmlwriter.net/xml_guide/entity_declaration.shtml **
|
|
<DOCTYPE first-element-in-doc formal-public-identifier-FPI>
|
|
** FPI is Owner//Keyword and Description//Language, -//Owner indicates
|
|
unregisterd and +//Owner indicates registered owner. ** Keyword can be
|
|
DTD,ELEMENT,ENTITIES or TEXT ** Description can be anything like "DocBook XML
|
|
my version V4.2" ** Language is 2 letter like EN for english -->
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"/usr/share/sgml/docbook/xml-dtd-4.2-1.0-19/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] >
|
|
<!--
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
[
|
|
<!ENTITY version "0.01">
|
|
] >
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"http://docbook.org/xml/4.2/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] > ********* **** For some reason file:// does not work. But why???
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"/usr/share/sgml/docbook/xml-dtd-4.2-1.0-19/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] >
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"file:/usr/share/sgml/docbook/xml-dtd-4.2-1.0-19/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] >
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"http://docbook.org/xml/4.2/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] >
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
|
|
<!ENTITY version "0.01">
|
|
] > -->
|
|
<article id="Vim-HOWTO">
|
|
<articleinfo>
|
|
<title>
|
|
Vim Color Editor HOW-TO (Vi Improved with syntax color highlighting)
|
|
</title>
|
|
<author>
|
|
<firstname>
|
|
Al Dev (Alavoor Vasudevan)
|
|
</firstname>
|
|
<authorblurb>
|
|
<para>
|
|
<ulink url="mailto: alavoor[AT]yahoo.com ">
|
|
alavoor[AT]yahoo.com
|
|
</ulink>
|
|
</para>
|
|
</authorblurb>
|
|
<affiliation>
|
|
<address format="linespecific">
|
|
<email>
|
|
alavoor[AT]yahoo.com
|
|
</email>
|
|
</address>
|
|
</affiliation>
|
|
</author>
|
|
<pubdate>
|
|
v19.5, 2 Nov 2003
|
|
</pubdate>
|
|
<abstract>
|
|
<para>
|
|
This document is a guide to quickly setting up the Vim color editor on
|
|
Linux or Unix systems. The information here will improve the
|
|
productivity of programmers because the Vim editor supports syntax
|
|
color highlighting and bold fonts, improving the "readability" of
|
|
program code. A programmer's productivity improves 2 to 3 times with a
|
|
color editor like Vim. The information in this document applies to all
|
|
operating sytems where Vim works, such as Linux, Windows 95/NT, Apple
|
|
Mac, IBM OSes, VMS, BeOS and all flavors of Unix like Solaris, HPUX,
|
|
AIX, SCO, Sinix, BSD, Ultrix etc.. (it means almost all operating
|
|
systems on this planet!)
|
|
</para>
|
|
</abstract>
|
|
</articleinfo>
|
|
<sect1 id="introduction">
|
|
<title>
|
|
Introduction
|
|
</title>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
(The latest version of this document is at
|
|
<ulink url="http://milkyway.has.it">
|
|
"http://milkyway.has.it"
|
|
</ulink>
|
|
and mirror at
|
|
<ulink url="http://www.milkywaygalaxy.freeservers.com">
|
|
"http://www.milkywaygalaxy.freeservers.com"
|
|
</ulink>
|
|
. You may want to check there for changes).
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Vim stands for 'Vi Improved'. Vi is the most popular and powerful
|
|
editors in the Unix world.
|
|
<emphasis remap="bf">
|
|
Vi
|
|
</emphasis>
|
|
is an abbreviation for "
|
|
<emphasis remap="it">
|
|
<emphasis remap="bf">
|
|
Vi
|
|
</emphasis>
|
|
</emphasis>
|
|
sual" editor. One of the first editors was a line editor called 'ed'
|
|
(and 'ex'). The
|
|
<emphasis remap="it">
|
|
<emphasis remap="bf">
|
|
Vi
|
|
</emphasis>
|
|
</emphasis>
|
|
sual editor like Vi was a vast improvement over line editors like 'ed'
|
|
(or 'ex'). The editors 'ed' and 'ex' are still available on Linux: see
|
|
'man ed' and 'man ex'.
|
|
</para>
|
|
<para>
|
|
A good editor improves programmer productivity. Vim supports color
|
|
syntax highlighting of program code and also emphasises text using
|
|
different fonts like normal, bold or italics. A color editor like Vim
|
|
can improve the
|
|
<emphasis remap="bf">
|
|
productivity
|
|
</emphasis>
|
|
of programmers by
|
|
<emphasis remap="bf">
|
|
2 to 3 times
|
|
</emphasis>
|
|
!! Programmers can read the code much more rapidly as the code syntax is
|
|
colored and highlighted.
|
|
</para>
|
|
<sect2 id="before-you-install">
|
|
<title>
|
|
Before you Install
|
|
</title>
|
|
<para>
|
|
Before you install Vim, please refer to the OS specific release notes
|
|
and information about compiling and usage of Vim at -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Go to this location and look for files os_*.txt
|
|
<ulink url="http://cvs.vim.org/cgi-bin/cvsweb/vim/runtime/doc">
|
|
"http://cvs.vim.org/cgi-bin/cvsweb/vim/runtime/doc"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
If you do not have the Vim package (RPM, DEB, tar, zip) then download
|
|
the Vim source code by ftp from the official Vim site
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
The home page of vim is at
|
|
<ulink url="http://www.vim.org">
|
|
"http://www.vim.org"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Mirror site in US is at
|
|
<ulink url="http://www.us.vim.org">
|
|
"http://www.us.vim.org"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Ftp site
|
|
<ulink url="ftp://ftp.vim.org/pub/vim">
|
|
"ftp://ftp.vim.org/pub/vim"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Or use one of the mirrors
|
|
<ulink url="ftp://ftp.vim.org/pub/vim/MIRRORS">
|
|
"ftp://ftp.vim.org/pub/vim/MIRRORS"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_redhat">
|
|
<title>
|
|
Install Vim on Redhat Linux
|
|
</title>
|
|
<para>
|
|
To use Vim install the following RPM packages on Redhat Linux -
|
|
<programlisting format="linespecific">
|
|
rpm -i vim*.rpm
|
|
OR do this -
|
|
rpm -i vim-enhanced*.rpm
|
|
rpm -i vim-X11*.rpm
|
|
rpm -i vim-common*.rpm
|
|
rpm -i vim-minimal*.rpm</programlisting>
|
|
You can see the list of files the vim rpm installs by -
|
|
<programlisting format="linespecific">
|
|
rpm -qa | grep ^vim | xargs rpm -ql | less
|
|
or
|
|
rpm -qa | grep ^vim | awk '{print "rpm -ql " $1 }' | /bin/sh | less</programlisting>
|
|
and browse output using j,k, CTRL+f, CTRL+D, CTRL+B, CTRL+U or using
|
|
arrow keys, page up/down keys. See 'man less'.
|
|
</para>
|
|
<para>
|
|
Note that the RPM packages for Redhat Linux use a Motif interface. If
|
|
you have installed the GTK libraries on your system, consider
|
|
compiling Vim from the source code for a clean GUI interface. For
|
|
information on compiling Vim from the source code, see "Install Vim on
|
|
Unixes", below.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_debian">
|
|
<title>
|
|
Install Vim on Debian GNU/Linux
|
|
</title>
|
|
<para>
|
|
To install Vim on Debian Linux (GNU Linux), login as root and when
|
|
connected to internet type -
|
|
<programlisting format="linespecific">
|
|
apt-get install vim vim-rt</programlisting>
|
|
It will download the latest version of vim, install it, configure it.
|
|
The first package listed is vim, the standard editor, compiled with
|
|
X11 support, vim-rt is the vim runtime, it holds all the syntax and
|
|
help files.
|
|
</para>
|
|
<para>
|
|
On Debian 3.0 (woody) and above, use 'apt-get install vim' instead.
|
|
The vim-rt package is part of the main vim package.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_unixes">
|
|
<title>
|
|
Install Vim on Unixes
|
|
</title>
|
|
<para>
|
|
For other flavors of unixes like Solaris, HPUX, AIX, Sinix, SCO
|
|
download the source code file ( see
|
|
<xref linkend="before-you-install"/>
|
|
)
|
|
<programlisting format="linespecific">
|
|
|
|
zcat vim.tar.gz | tar -xvf -
|
|
cd vim-5.5/src
|
|
./configure --prefix=$HOME/local
|
|
make
|
|
make install</programlisting>
|
|
You can exclude prefix option if you want to install in default
|
|
location in /usr/local. If the graphics version 'gvim' gives trouble
|
|
then try with
|
|
<programlisting format="linespecific">
|
|
./configure --prefix=$HOME/local --enable-gui=motif</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_mswin">
|
|
<title>
|
|
Install Vim on Microsoft Windows 95/NT
|
|
</title>
|
|
<para>
|
|
See
|
|
<xref linkend="installmswin"/>
|
|
.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_vms">
|
|
<title>
|
|
Install Vim on VMS
|
|
</title>
|
|
<sect3 id="download_files">
|
|
<title>
|
|
Download files
|
|
</title>
|
|
<para>
|
|
You will need both the Unix and Extra archives to build vim.exe for
|
|
VMS. For using Vim's full power you will need the runtime files as
|
|
well. Get these files ( see
|
|
<xref linkend="before-you-install"/>
|
|
)
|
|
</para>
|
|
<para>
|
|
You can download precompiled executables from:
|
|
<ulink url="http://www.polarfox.com/vim">
|
|
"http://www.polarfox.com/vim"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
VMS vim authors are -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="mailto: zoltan.arpadffy@essnet.se ">
|
|
zoltan.arpadffy@essnet.se
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="mailto: arpadffy@altavista.net ">
|
|
arpadffy@altavista.net
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="mailto: cec@gryphon.gsfc.nasa.gov ">
|
|
cec@gryphon.gsfc.nasa.gov
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="mailto: BNHunsaker@chq.byu.edu ">
|
|
BNHunsaker@chq.byu.edu
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="mailto: sandor.kopanyi@altavista.net ">
|
|
sandor.kopanyi@altavista.net
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="compiling">
|
|
<title>
|
|
Compiling
|
|
</title>
|
|
<para>
|
|
Unpack the Unix and Extra archives together into one directory. In
|
|
the <.SRC> subdirectory you should find the make file
|
|
OS_VMS.MMS. By editing this file you may choose between building the
|
|
character, GUI and debug version. There are also additional options
|
|
for Perl, Python and Tcl support.
|
|
</para>
|
|
<para>
|
|
You will need either the DECSET mms utility or the freely available
|
|
clone of it called mmk (VMS has no make utility in the standard
|
|
distribution). You can download mmk from
|
|
http://www.openvms.digital.com/freeware/MMK/
|
|
</para>
|
|
<para>
|
|
If you have MSS on your system, the command
|
|
</para>
|
|
<para>
|
|
> mms /descrip=os_vms.mms
|
|
</para>
|
|
<para>
|
|
will start building your own customised version of Vim. The
|
|
equivalent command for mmk is:
|
|
</para>
|
|
<para>
|
|
> mmk /descrip=os_vms.mms
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="deploy">
|
|
<title>
|
|
Deploy
|
|
</title>
|
|
<para>
|
|
Vim uses a special directory structure to hold the document and
|
|
runtime files:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
vim (or wherever)
|
|
|- tmp
|
|
|- vim55
|
|
|----- doc
|
|
|----- syntax
|
|
|- vim56
|
|
|----- doc
|
|
|----- syntax
|
|
vimrc (system rc files)
|
|
gvimrc
|
|
Use:
|
|
> define/nolog device:[leading-path-here.vim] vim
|
|
> define/nolog device:[leading-path-here.vim.vim56] vimruntime
|
|
> define/nolog device:[leading-path-here.tmp] tmp</programlisting>
|
|
</para>
|
|
<para>
|
|
to get vim.exe to find its document, filetype, and syntax files, and
|
|
to specify a directory where temporary files will be located. Copy
|
|
the "runtime" subdirectory of the vim distribution to vimruntime.
|
|
</para>
|
|
<para>
|
|
Note: Logicals $VIMRUNTIME and $TMP are optional. Read more at :help
|
|
runtime
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="practical_usage">
|
|
<title>
|
|
Practical usage
|
|
</title>
|
|
<para>
|
|
Usually you want to run just one version of Vim on your system,
|
|
therefore it is enough to dedicate one directory for Vim. Copy all
|
|
Vim runtime directory structure to the deployment position. Add the
|
|
following lines to your LOGIN.COM (in SYS$LOGIN directory). Set up
|
|
logical $VIM as:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
> $ define VIM device: <path></programlisting>
|
|
</para>
|
|
<para>
|
|
Set up some symbols:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
> $ ! vi starts Vim in chr. mode.
|
|
> $ vi*m :== mcr device:<path>VIM.EXE
|
|
> $ !gvi starts Vim in GUI mode.
|
|
> $ gv*im :== spawn/nowait mcr device:<path>VIM.EXE -g</programlisting>
|
|
</para>
|
|
<para>
|
|
Create .vimrc and .gvimrc files in your home directory (SYS$LOGIN).
|
|
</para>
|
|
<para>
|
|
The easiest way is just rename example files. You may leave the menu
|
|
file (MENU.VIM) and files vimrc and gvimrc in the original $VIM
|
|
directory. It will be default setup for all users, and for users is
|
|
enough just to have their own additions or resetting in home
|
|
directory in files .vimrc and .gvimrc. It should work without
|
|
problems.
|
|
</para>
|
|
<para>
|
|
Note: Remember, system rc files (default for all users) do not have
|
|
the leading "." So, system rc files are:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
> VIM$:vimrc
|
|
> VIM$:gvimrc
|
|
> VIM$:menu.vim</programlisting>
|
|
and user's customised rc files are:
|
|
<programlisting format="linespecific">
|
|
> sys$login:.vimrc
|
|
> sys$login:.gvimrc</programlisting>
|
|
</para>
|
|
<para>
|
|
You can check that everything is on the right place with the
|
|
:version command.
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
Example LOGIN.COM:
|
|
> $ define/nolog VIM RF10:[UTIL.VIM]
|
|
> $ vi*m :== mcr VIM:VIM.EXE
|
|
> $ gv*im :== spawn/nowait mcr VIM:VIM.EXE -g
|
|
> $ set disp/create/node=192.168.5.223/trans=tcpip</programlisting>
|
|
</para>
|
|
<para>
|
|
Note: This set-up should be enough if you are working in a
|
|
standalone server or clustered environment, but if you want to use
|
|
Vim as an internode editor, it should suffice. You just have to
|
|
define the "whole" path:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
> $ define VIM "<server_name>[""user password""]::device:<path>"
|
|
> $ vi*m :== "mcr VIM:VIM.EXE"</programlisting>
|
|
</para>
|
|
<para>
|
|
as for example:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
> $ define VIM "PLUTO::RF10:[UTIL.VIM]"
|
|
> $ define VIM "PLUTO""ZAY mypass""::RF10:[UTIL.VIM]" ! if passwd required</programlisting>
|
|
</para>
|
|
<para>
|
|
You can also use $VIMRUNTIME logical to point to proper version of
|
|
Vim if you have multiple versions installed at the same time. If
|
|
$VIMRUNTIME is not defined Vim will borrow value from $VIM logical.
|
|
You can find more information about $VIMRUNTIME logical by typing
|
|
:help runtime as a Vim command.
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="gui_mode_qns">
|
|
<title>
|
|
GUI mode questions
|
|
</title>
|
|
<para>
|
|
VMS is not a native X window environment, so you can not start Vim
|
|
in GUI mode "just like that". But it is not too complicated to get a
|
|
running Vim.
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
1) If you are working on the VMS X console:
|
|
Start Vim with the command:
|
|
> $ mc device:<path>VIM.EXE -g
|
|
or type :gui as a command to the Vim command prompt. For more info :help gui
|
|
2) If you are working on other X window environment as Unix or some remote X
|
|
VMS console. Set up display to your host with:
|
|
> $ set disp/create/node=<your IP address>/trans=<transport-name>
|
|
and start Vim as in point 1. You can find more help in VMS documentation or
|
|
type: help set disp in VMS prompt.
|
|
Examples:
|
|
> $ set disp/create/node=192.168.5.159 ! default trans is DECnet
|
|
> $ set disp/create/node=192.168.5.159/trans=tcpip ! TCP/IP network
|
|
> $ set disp/create/node=192.168.5.159/trans=local ! display on the same node</programlisting>
|
|
</para>
|
|
<para>
|
|
Note: you should define just one of these. For more information type
|
|
$help set disp in VMS prompt.
|
|
</para>
|
|
</sect3>
|
|
</sect2>
|
|
<sect2 id="vim_on_os2">
|
|
<title>
|
|
Install Vim on OS/2
|
|
</title>
|
|
<para>
|
|
Read the release notes for Vim on OS/2, see
|
|
<xref linkend="before-you-install"/>
|
|
.
|
|
</para>
|
|
<para>
|
|
At present there is no native PM version of the GUI version of vim:
|
|
The OS/2 version is a console application. However, there is now a
|
|
Win32s-compatible GUI version, which should be usable by owners of
|
|
Warp 4 (which supports Win32s) in a Win-OS/2 session. The notes in
|
|
this file refer to the native console version.
|
|
</para>
|
|
<para>
|
|
To run Vim, you need the emx runtime environment (at least rev. 0.9b).
|
|
This is generally available as (ask Archie about it):
|
|
<programlisting format="linespecific">
|
|
emxrt.zip emx runtime package</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_on_mac">
|
|
<title>
|
|
Install Vim on Apple Macintosh
|
|
</title>
|
|
<para>
|
|
Read the release notes for Vim on OS/2, see
|
|
<xref linkend="before-you-install"/>
|
|
.
|
|
</para>
|
|
<para>
|
|
The author of Vim on Mac (old version vim 3.0) is
|
|
<programlisting format="linespecific">
|
|
Eric Fischer
|
|
5759 N. Guilford Ave
|
|
Indianapolis IN 46220 USA</programlisting>
|
|
Email to
|
|
<ulink url="mailto: enf@pobox.com ">
|
|
enf@pobox.com
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Mac Bug Report When reporting any Mac specific bug or feature change,
|
|
makes sure to include the following address in the "To:" or "Copy To:"
|
|
field.
|
|
</para>
|
|
<para>
|
|
<ulink url="mailto: dany.stamant@sympatico.ca ">
|
|
dany.stamant@sympatico.ca
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Vim compiles out of the box with the supplied CodeWarrior project when
|
|
using CodeWarrior 9. If you are using a more recent version (e. g. CW
|
|
Pro) you have to convert the project first. When compiling Vim for 68k
|
|
Macs you have to open the "size" resource in ResEdit and enable the
|
|
"High level events aware" button to get drag and drop working. You
|
|
have to increase the memory partition to at least 1024 kBytes to
|
|
prevent Vim from crashing due to low memory.
|
|
<programlisting format="linespecific">
|
|
vim:ts=8:sw=8:tw=78:</programlisting>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="installmswin">
|
|
<title>
|
|
Install Vim on Microsoft Windows 95/NT
|
|
</title>
|
|
<para>
|
|
For Windows 95/NT, download the Vim zip file. Double click on the
|
|
vim.exe and
|
|
<emphasis remap="bf">
|
|
do "FULL" install and not "Typical"
|
|
</emphasis>
|
|
to get graphics and colors.
|
|
</para>
|
|
<para>
|
|
If you decide download in parts, then you must download
|
|
<emphasis remap="bf">
|
|
TWO
|
|
</emphasis>
|
|
zip files -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Runtime support file
|
|
<emphasis remap="bf">
|
|
vim*rt.zip
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vim command file
|
|
<emphasis remap="bf">
|
|
vim*60.zip
|
|
</emphasis>
|
|
. Where Vim version is 5.6.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
Get one big executable or two zip files from: Goto
|
|
<ulink url="http://www.vim.org">
|
|
"http://www.vim.org"
|
|
</ulink>
|
|
and click on Download-> download FAQ-> Windows 95/NT or click on
|
|
these
|
|
<ulink url="ftp://vim.ftp.fu-berlin.de/pc/gvim60.zip">
|
|
"ftp://vim.ftp.fu-berlin.de/pc/gvim60.zip"
|
|
</ulink>
|
|
and
|
|
<ulink url="ftp://vim.ftp.fu-berlin.de/pc/vim60rt.zip">
|
|
"ftp://vim.ftp.fu-berlin.de/pc/vim60rt.zip"
|
|
</ulink>
|
|
. ( see also
|
|
<xref linkend="before-you-install"/>
|
|
)
|
|
</para>
|
|
<para>
|
|
Unpack the zip files using the Winzip
|
|
<ulink url="http://www.winzip.com">
|
|
"http://www.winzip.com"
|
|
</ulink>
|
|
. Both the zip files (vim*rt.zip and vim*60.zip) must be unpacked in the
|
|
same directory like say
|
|
<emphasis remap="bf">
|
|
c:\vim
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
<para>
|
|
For Windows 95/98, set the environment variable VIM (all caps no
|
|
lowercase) in autoexec.bat by adding this line -
|
|
<programlisting format="linespecific">
|
|
set VIM=c:\vim\vim60</programlisting>
|
|
For Windows NT, add the environment variable VIM (all caps no lowercase)
|
|
to the
|
|
<emphasis remap="bf">
|
|
Start | Control Panel | System | Environment | System Properties
|
|
</emphasis>
|
|
dialog. For Windows 2000, click on
|
|
<emphasis remap="bf">
|
|
Start | Control Panel | System | Advanced | Environment Variable
|
|
</emphasis>
|
|
dialog and add variable VIM (all caps no lowercase):
|
|
<programlisting format="linespecific">
|
|
VIM=c:\vim\vim60</programlisting>
|
|
</para>
|
|
<para>
|
|
The VIM variable should point to wherever you installed the vim60
|
|
directory. You can also set your PATH to include the gvim.exe's path.
|
|
</para>
|
|
<para>
|
|
You may need to logoff and relogin to set your environment. Bring up a
|
|
MS-DOS window by click on Start->Programs->MSDOS (for Windows
|
|
95/98) and Start->Run->cmd (for Windows NT/2000). At an MS-DOS
|
|
prompt type -
|
|
<programlisting format="linespecific">
|
|
c:\> set vim
|
|
c:\> cd vim\vim60
|
|
c:\> install.exe</programlisting>
|
|
For 'set vim' command, you should see - VIM=c:\vim\vim60 and start the
|
|
install program which will setup the enviroment.
|
|
</para>
|
|
<para>
|
|
Create a short-cut on to your desktop by click-and-drag from
|
|
c:\vim\vim60\gvim.exe.
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Color Syntax Highlighting:
|
|
</emphasis>
|
|
To enable color syntaxt highlighting and other nice features you must
|
|
copy the gvimrc_example file to the $VIM\_gvimrc. In my case it is
|
|
c:\vim\vim60\_gvimrc.
|
|
<programlisting format="linespecific">
|
|
c:\> copy c:\vim\vim60\gvimrc_example $VIM\_gvimrc</programlisting>
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Useful Tips :
|
|
</emphasis>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Just double click on gvim icon on desktop and click
|
|
MyComputer->C:drive->Select a file and drag and drop it into
|
|
the gvim window. The file is automatically opened by gvim window!!
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
To automatically maximize the Vim window in MS Windows, you can
|
|
use
|
|
<ulink url="http://www.southbaypc.com/AutoSizer">
|
|
"http://www.southbaypc.com/AutoSizer"
|
|
</ulink>
|
|
or you can right click on Gvim shortcut and select properties and
|
|
pick maximize the window on startup.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<sect2 id="install_bash">
|
|
<title>
|
|
Install bash shell
|
|
</title>
|
|
<para>
|
|
In order make MS Windows 95/98/NT/2000/XP even more user-friendly,
|
|
install the bash shell (Bourne Again Shell). Install
|
|
<ulink url="http://sources.redhat.com/cygwin/setup.exe">
|
|
"http://sources.redhat.com/cygwin/setup.exe"
|
|
</ulink>
|
|
(Cygwin-setup program) and select bash and other common utilities. The
|
|
CygWin main site is at
|
|
<ulink url="http://sources.redhat.com/cygwin">
|
|
"http://sources.redhat.com/cygwin"
|
|
</ulink>
|
|
. With CygWin the Windows 2000 computer will look like Linux/Unix
|
|
box!! And combined with gvim editor, the Windows 2000 gives
|
|
programmers more power. The cygwin home is at
|
|
<ulink url="http://cygwin.com">
|
|
"http://cygwin.com"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<para>
|
|
You may also want to install MKS in case you are planning to use Java
|
|
and Java compilers. Get MKS from
|
|
<ulink url="http://www.mks.com">
|
|
"http://www.mks.com"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="edit_bash_profile">
|
|
<title>
|
|
Edit bash_profile
|
|
</title>
|
|
<para>
|
|
After installing the Cygwin, insert some useful aliases in
|
|
~/.bash_profile file. Open a cygwin window and at bash prompt -
|
|
<programlisting format="linespecific">
|
|
bash$ cd $HOME
|
|
bash$ gvim .bash_profile
|
|
set -o vi
|
|
alias ls='ls --color '
|
|
alias cp='cp -i '
|
|
alias mv='mv -i '
|
|
alias rm='rm -i '
|
|
alias vi='gvim '
|
|
alias vip='gvim ~/.bash_profile & '
|
|
alias sop='. ~/.bash_profile '
|
|
alias mys='mysql -uroot -p '
|
|
PATH=$PATH:"/cygdrive/c/Program Files/mysql/bin"</programlisting>
|
|
With color ls, when you do ls you will see all the directory names and
|
|
files in different colors (it looks great!!). With set -o vi, you can
|
|
use the command line history editing just as in linux.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="window_colors">
|
|
<title>
|
|
Setup Window colors
|
|
</title>
|
|
<para>
|
|
The default background color of MS DOS prompt window is black and
|
|
white text. You must change the color, fontsize and window size to
|
|
make it more pleasing. On MS Windows 2000, click on button
|
|
Start->Run and type "cmd" and hit return. On MS Windows 95/98/NT
|
|
click on Start->Programs->MSDOS Prompt which will bring up MSDOS
|
|
window. Right click on the top left corner of the MSDOS prompt window
|
|
and select properties. Select color background and enter R=255, G=255,
|
|
B=190 (red, green, blue) for lightyellow background and text
|
|
foreground color to black (R=0, G=0, B=0). This sets background to
|
|
light yellow and text foreground to black and this combination is most
|
|
pleasing to human eyes. If you have problems with colors in cygwin
|
|
bash window when doing 'man ls', set the text color to "marune".
|
|
</para>
|
|
<para>
|
|
For Windows95 see
|
|
<ulink url="http://www.elementkjournals.com/w95/9711/w9597b3.htm">
|
|
Color for MS-DOS prompt window
|
|
</ulink>
|
|
.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="notepad">
|
|
<title>
|
|
MS Windows Notepad and Wordpad Imitator in Vim
|
|
</title>
|
|
<para>
|
|
Is there a MS Windows Notepad or Wordpad for Linux or Unix? Yes there
|
|
is!! For those non-technical users of MS Windows who extensively use the
|
|
Notepad and Wordpad, there is a command 'evim' which imitates the
|
|
Notepad and Wordpad. The 'evim' is exactly like Notepad and Wordpad and
|
|
has all their functionalities. You need to install the package vim-X11
|
|
package to enable evim.
|
|
<programlisting format="linespecific">
|
|
bash$ evim <filename></programlisting>
|
|
</para>
|
|
<para>
|
|
On Unixes like HPUX, Solaris, AIX do these:
|
|
<programlisting format="linespecific">
|
|
ln -s /usr/local/bin/vim /usr/local/bin/gvim
|
|
ln -s /usr/local/bin/vim /usr/local/bin/evim
|
|
|
|
Create a command file 'notepad' in /usr/local/bin/notepad with these 2 lines below:
|
|
#!/bin/sh
|
|
/usr/local/bin/evim $@
|
|
</programlisting>
|
|
If evim is linked to vim it automatically launches evim. Or you can set
|
|
up alias for evim and givm as below:
|
|
<programlisting format="linespecific">
|
|
alias evim='vim -g -U /usr/local/vim/share/vim/vim61/evim.vim '
|
|
alias gvim='vim -g '
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
Wordpad for Unix/Linux? Look at TED, AbiWord and OpenOffice. Visit
|
|
<ulink url="http://www.nllgg.nl/Ted">
|
|
TED - A Wordpad for Linux
|
|
</ulink>
|
|
or
|
|
<ulink url="http://www.abiword.org">
|
|
AbiWord - Light weight, small software
|
|
</ulink>
|
|
or
|
|
<ulink url="http://www.openoffice.org">
|
|
OpenOffice - Heavy weight, big software
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<para>
|
|
See also Wine project which has notepad and wordpad
|
|
<ulink url="http://www.winehq.org">
|
|
WINE project
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<sect2 id="editplus">
|
|
<title>
|
|
MS Windows EditPlus Features in Vim
|
|
</title>
|
|
<para>
|
|
Vim has many of the features of EditPlus editor and in near future
|
|
will try incorporate many good features of EditPlus editor :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Left hand side File Navigator - In Vim (gvim) click on menu
|
|
Window-> 'Split File Explorer' and ajust the width of file
|
|
explorer window.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Connect direct to remote host via ftp and handle automatically
|
|
the edits and uploads (looks as if the remote files and folders
|
|
are in local host).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Many other features
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
The EditPlus is at
|
|
<ulink url="http://www.editplus.com">
|
|
EditPlus
|
|
</ulink>
|
|
. See also
|
|
<ulink url="http://www.textpad.com">
|
|
TextPad
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.ultraedit.com">
|
|
UltraEdit
|
|
</ulink>
|
|
.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="gvim_init">
|
|
<title>
|
|
Setup gvim init files
|
|
</title>
|
|
<para>
|
|
To enable the syntax color highlighting you MUST copy the gvimrc file to
|
|
your home directory. This will also put the "Syntax" Menu with gvim
|
|
command. You can click on Syntax Menu and select appropriate languages
|
|
like C++, Perl, Java, SQL, ESQL etc..
|
|
<programlisting format="linespecific">
|
|
cd $HOME
|
|
cp /usr/doc/vim-common-5.3/gvimrc_example ~/.gvimrc</programlisting>
|
|
Comment lines in .gvimrc begin with double-quotes ("). You can customize
|
|
gvim by editing the file $HOME/.gvimrc and put the following lines -
|
|
<programlisting format="linespecific">
|
|
" This line is a comment .... one which begins with double-quotes
|
|
" The best is the bold font, try all of these and pick one....
|
|
set guifont=8x13bold
|
|
"set guifont=9x15bold
|
|
"set guifont=7x14bold
|
|
"set guifont=7x13bold
|
|
"
|
|
" Highly recommended to set tab keys to 4 spaces
|
|
set tabstop=4
|
|
set shiftwidth=4
|
|
"
|
|
" The opposite is 'set wrapscan' while searching for strings....
|
|
set nowrapscan
|
|
"
|
|
" The opposite is set noignorecase
|
|
set ignorecase
|
|
set autoindent
|
|
"
|
|
" You may want to turn off the beep sounds (if you want quite) with visual bell
|
|
" set vb
|
|
" Source in your custom filetypes as given below -
|
|
" so $HOME/vim/myfiletypes.vim</programlisting>
|
|
It is
|
|
<emphasis remap="bf">
|
|
very strongly
|
|
</emphasis>
|
|
recommended that you set the
|
|
<emphasis remap="it">
|
|
tabstop
|
|
</emphasis>
|
|
to 4 and
|
|
<emphasis remap="it">
|
|
shiftwidth
|
|
</emphasis>
|
|
to 4. The
|
|
<emphasis remap="it">
|
|
tabstop
|
|
</emphasis>
|
|
is the number of spaces the TAB key will indent while editing with gvim.
|
|
The
|
|
<emphasis remap="it">
|
|
shiftwidth
|
|
</emphasis>
|
|
is the number of spaces the lines will be shifted with "> > " or "
|
|
< < " vi commands. Refer to Vi tutorials
|
|
<xref linkend="vim-tutorial"/>
|
|
for more details.
|
|
</para>
|
|
<para>
|
|
To see the list of available fonts on Linux/Unix see the command
|
|
<emphasis remap="bf">
|
|
xlsfonts
|
|
</emphasis>
|
|
. Type -
|
|
<programlisting format="linespecific">
|
|
bash$ xlsfonts | less
|
|
bash$ xlsfonts | grep -i bold | grep x
|
|
bash$ man xlsfonts</programlisting>
|
|
</para>
|
|
<sect2 id="gvimrc_file">
|
|
<title>
|
|
Sample gvimrc file
|
|
</title>
|
|
<para>
|
|
You can change the settings like color, bold/normal fonts in your
|
|
$HOME/.gvimrc file. It is
|
|
<emphasis remap="bf">
|
|
very strongly
|
|
</emphasis>
|
|
recommended that you set the background color to
|
|
<emphasis remap="it">
|
|
lightyellow
|
|
</emphasis>
|
|
or
|
|
<emphasis remap="it">
|
|
white
|
|
</emphasis>
|
|
with
|
|
<emphasis remap="it">
|
|
black
|
|
</emphasis>
|
|
foreground. Ergonomics says that best background color is
|
|
<emphasis remap="it">
|
|
lightyellow
|
|
</emphasis>
|
|
or
|
|
<emphasis remap="it">
|
|
white
|
|
</emphasis>
|
|
with
|
|
<emphasis remap="it">
|
|
black
|
|
</emphasis>
|
|
foreground. Hence change the variable 'guibg' in your $HOME/.gvimrc
|
|
file as follows:
|
|
<programlisting format="linespecific">
|
|
highlight Normal guibg=lightyellow</programlisting>
|
|
</para>
|
|
<para>
|
|
The sample gvimrc from /usr/doc/vim-common-5.3/gvimrc_example is as
|
|
follows:
|
|
<programlisting format="linespecific">
|
|
" Vim
|
|
" An example for a gvimrc file.
|
|
" The commands in this are executed when the GUI is started.
|
|
"
|
|
" To use it, copy it to
|
|
" for Unix and OS/2: ~/.gvimrc
|
|
" for Amiga: s:.gvimrc
|
|
" for MS-DOS and Win32: $VIM\_gvimrc
|
|
" Make external commands work through a pipe instead of a pseudo-tty
|
|
"set noguipty
|
|
" set the X11 font to use. See 'man xlsfonts' on unix/linux
|
|
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
|
|
set guifont=8x13bold
|
|
"set guifont=9x15bold
|
|
"set guifont=7x14bold
|
|
"set guifont=7x13bold
|
|
"
|
|
" Highly recommended to set tab keys to 4 spaces
|
|
set tabstop=4
|
|
set shiftwidth=4
|
|
"
|
|
" The opposite is 'set wrapscan' while searching for strings....
|
|
set nowrapscan
|
|
"
|
|
" The opposite is set noignorecase
|
|
set ignorecase
|
|
"
|
|
" You may want to turn off the beep sounds (if you want quite) with visual bell
|
|
" set vb
|
|
" Source in your custom filetypes as given below -
|
|
" so $HOME/vim/myfiletypes.vim
|
|
" Make command line two lines high
|
|
set ch=2
|
|
" Make shift-insert work like in Xterm
|
|
map <S-Insert> <MiddleMouse>
|
|
map! <S-Insert> <MiddleMouse>
|
|
" Only do this for Vim version 5.0 and later.
|
|
if version >= 500
|
|
" I like highlighting strings inside C comments
|
|
let c_comment_strings=1
|
|
" Switch on syntax highlighting.
|
|
syntax on
|
|
" Switch on search pattern highlighting.
|
|
set hlsearch
|
|
" For Win32 version, have "K" lookup the keyword in a help file
|
|
"if has("win32")
|
|
" let winhelpfile='windows.hlp'
|
|
" map K :execute "!start winhlp32 -k <cword> " . winhelpfile <CR>
|
|
"endif
|
|
" Hide the mouse pointer while typing
|
|
set mousehide
|
|
" Set nice colors
|
|
" background for normal text is light grey
|
|
" Text below the last line is darker grey
|
|
" Cursor is green
|
|
" Constants are not underlined but have a slightly lighter background
|
|
highlight Normal guibg=grey90
|
|
highlight Cursor guibg=Green guifg=NONE
|
|
highlight NonText guibg=grey80
|
|
highlight Constant gui=NONE guibg=grey95
|
|
highlight Special gui=NONE guibg=grey95
|
|
endif</programlisting>
|
|
See also sample vimrc used for console mode vim command from
|
|
/usr/doc/vim-common-5.3/vimrc_example.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="xdefaults">
|
|
<title>
|
|
Xdefaults parameters
|
|
</title>
|
|
<para>
|
|
You can set some of the Vim properties in Xdefaults file.
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
WARNING:
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
Do not set
|
|
<emphasis remap="bf">
|
|
Vim*geometry
|
|
</emphasis>
|
|
as it will break the gvim menu, use
|
|
<emphasis remap="bf">
|
|
Vim.geometry
|
|
</emphasis>
|
|
instead
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
<para>
|
|
Edit the $HOME/.Xdefaults file and add the following lines:
|
|
<programlisting format="linespecific">
|
|
! GVim great Colors.
|
|
Vim*useSchemes: all
|
|
Vim*sgiMode: true
|
|
Vim*useEnhancedFSB: true
|
|
Vim.foreground: Black
|
|
!Vim.background: lightyellow2
|
|
Vim*background: white
|
|
! Do NOT use Vim*geometry , this will break the menus instead
|
|
! use Vim.geometry. Asterisk between Vim and geometry is not allowed.
|
|
! Vim.geometry: widthxheight
|
|
Vim.geometry: 88x40
|
|
!Vim*font: -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-15-*5
|
|
Vim*menuBackground: yellow
|
|
Vim*menuForeground: black</programlisting>
|
|
In order for this change to take effect, type -
|
|
<programlisting format="linespecific">
|
|
xrdb -merge $HOME/.Xdefaults
|
|
man xrdb</programlisting>
|
|
</para>
|
|
<para>
|
|
You can also edit the ~/.gvimrc file to change the background colors
|
|
<programlisting format="linespecific">
|
|
gvim $HOME/.gvimrc
|
|
The best background color is lightyellow or white, with black foreground.
|
|
highlight Normal guibg=lightyellow</programlisting>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="color_syntax">
|
|
<title>
|
|
Color Syntax init files
|
|
</title>
|
|
<sect2 id="auto_source">
|
|
<title>
|
|
Auto source-in method
|
|
</title>
|
|
<para>
|
|
This section below is obtained from gvim session by typing 'help
|
|
syntax' -
|
|
<programlisting format="linespecific">
|
|
bash$ gvim some_test
|
|
:help syntax</programlisting>
|
|
Click on the menu Window=>Close_Others to close other Window. And
|
|
then do CTRL+] on 'Syntax Loading Procedure' menu which will take you
|
|
there. (Use CTRL+T to rewind and go back).
|
|
</para>
|
|
<para>
|
|
If a file type you want to use is not detected, then there are two
|
|
ways to add it.
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Method 1:
|
|
</emphasis>
|
|
You can modify the
|
|
<emphasis remap="it">
|
|
$VIMRUNTIME/filetype.vim
|
|
</emphasis>
|
|
file, but this is not recommended as it will be overwritten when you
|
|
install a new version of Vim.
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Method 2:
|
|
</emphasis>
|
|
Create a file in $HOME/vim/myfiletypes.vim and put these lines in it -
|
|
<programlisting format="linespecific">
|
|
"
|
|
" *************************************************************
|
|
" Filename : $HOME/vim/myfiletypes.vim
|
|
" See the document by typing :help autocmd within vim session
|
|
" see also the doc at /usr/share/vim/doc/autocmd.txt
|
|
" This file will setup the autocommands for new filetypes
|
|
" using the existing syntax-filetypes.
|
|
" For example when you open foo.prc it will use syntax of plsql
|
|
" Basically does :set filetype=prc inside vim
|
|
" Add a line in $HOME/.gvimrc as below:
|
|
" so $HOME/vim/myfiletypes.vim
|
|
"
|
|
" *************************************************************
|
|
augroup filetype
|
|
au!
|
|
au! BufRead,BufNewFile *.phc set filetype=php
|
|
au! BufRead,BufNewFile *.mine set filetype=mine
|
|
au! BufRead,BufNewFile *.xyz set filetype=drawing
|
|
au! BufRead,BufNewFile *.prc set filetype=plsql
|
|
augroup END</programlisting>
|
|
Then add a line in your $HOME/.vimrc and $HOME/.gvimrc file to source
|
|
in the file "myfiletypes.vim". (
|
|
<emphasis remap="bf">
|
|
CAUTION:
|
|
</emphasis>
|
|
You MUST put this in both vimrc and gvimrc files in order for this to
|
|
work) Example:
|
|
<programlisting format="linespecific">
|
|
so $HOME/vim/myfiletypes.vim</programlisting>
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
NOTE:
|
|
</emphasis>
|
|
Make sure that you set "so myfiletypes.vim" before switching on file
|
|
type detection. This is must be before any ":filetype on" or ":syntax
|
|
on" command.
|
|
</para>
|
|
<para>
|
|
See the documentation on autocommand at -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:help autocmd
|
|
</emphasis>
|
|
(within a vim editing session)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
See also the doc at /usr/share/vim/doc/autocmd.txt
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
Your file will then be sourced in after the default FileType
|
|
autocommands have been installed. This allows you to overrule any of
|
|
the defaults, by using ":au!" to remove any existing FileType
|
|
autocommands for the same pattern. Only the autocommand to source the
|
|
scripts.vim file is given later. This makes sure that your
|
|
autocommands in "myfiletypes.vim" are used before checking the
|
|
contents of the file.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="manual_method">
|
|
<title>
|
|
Manual method
|
|
</title>
|
|
<para>
|
|
Instead of using "Syntax" menu you can also manually source in the
|
|
syntax file. Edit the file with gvim and at : (colon) command give
|
|
'so' command. For example -
|
|
<programlisting format="linespecific">
|
|
gvim foo.pc
|
|
:so $VIM/syntax/esqlc.vim</programlisting>
|
|
The syntax source files are at /usr/share/vim/syntax/*.vim. Vim
|
|
supports more than 120 different syntax files for different languages
|
|
like C++, PERL, VHDL, JavaScript,...and so on!!
|
|
</para>
|
|
<para>
|
|
Each syntax file supports one or more default file name extensions,
|
|
for example, JavaScript syntax file supports the *.js extension. If
|
|
you happen to use an extension that conflicts with another default
|
|
syntax file (such as adding JavaScript to a *.html file) than you can
|
|
source in the additional syntax file with the command :so
|
|
$VIM/syntax/javascript.vim. To avoid all of this typing, you can
|
|
create a soft link like -
|
|
<programlisting format="linespecific">
|
|
ln -s $VIM/syntax/javascript.vim js
|
|
gvim foo.html (... this file contains javascript functions and HTML)
|
|
:so js</programlisting>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="vim_usage">
|
|
<title>
|
|
VIM Usage
|
|
</title>
|
|
<para>
|
|
You can use Vim in two modes - one with GUI and other without GUI. To
|
|
use GUI use command -
|
|
<programlisting format="linespecific">
|
|
gvim foo.cpp</programlisting>
|
|
To use non-gui mode give -
|
|
<programlisting format="linespecific">
|
|
vim foo.cpp
|
|
OR plain vanilla mode
|
|
vi foo.cpp</programlisting>
|
|
It is very strongly recommended that you always use gvim instead of vim,
|
|
since GUI mode with colors will definitely improve your productivity.
|
|
The vim also gives colors but cannot set the background colors and gvim
|
|
can set the background and foreground colors.
|
|
</para>
|
|
<para>
|
|
GUI mode gvim provides the following -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
You can mark the text using the mouse to do cut, copy and paste.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
You can use the Menu bar which has - File, Edit, Window, Tools,
|
|
Synatx and Help buttons.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Also in near future in gvim - a second menu bar will display the
|
|
list of files being edited, and you can switch files by clicking
|
|
on the filenames, until then you can use vi commands - :e#, :e#1,
|
|
:e#2, :e#3, :e#4, ....so on to select the files.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="remote_vi">
|
|
<title>
|
|
Remote Vi - MS Windows QVWM Manager
|
|
</title>
|
|
<para>
|
|
QVWM Window Manager is the best as it is very similar in appearance to
|
|
Microsoft Windows. If you want to use Vi and Vim remotely from a MS
|
|
Windows PC client, then you should use VNC + QVWM manager. Servers are
|
|
generally located in remote Data Centers and to edit the files, you
|
|
should first login to remote servers from MS Windows or Linux desktop
|
|
PCs. After starting VNC server and QVWM manager on remote server, you
|
|
should fire up
|
|
<emphasis remap="bf">
|
|
vncviewer
|
|
</emphasis>
|
|
on your client desktop and edit remote files with
|
|
<emphasis remap="bf">
|
|
gvim
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
<para>
|
|
To use graphical editor like
|
|
<emphasis remap="bf">
|
|
gvim
|
|
</emphasis>
|
|
for remote operations, use the following techniques below:
|
|
</para>
|
|
<para>
|
|
You can use the VNC to display remote machines on your local display.
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
The VNC is at
|
|
<ulink url="http://www.uk.research.att.com/vnc">
|
|
"http://www.uk.research.att.com/vnc"
|
|
</ulink>
|
|
and commercial VNC is at
|
|
<ulink url="http://www.realvnc.com">
|
|
"http://www.realvnc.com"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Get VNC rpms from
|
|
<ulink url="http://rpmfind.net/linux/rpm2html/search.php?query=vnc">
|
|
rpmfind
|
|
</ulink>
|
|
or from commercial VNC at
|
|
<ulink url="http://www.realvnc.com">
|
|
"http://www.realvnc.com"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
The best Window manager for VNC is QVWM which is like MS Windows
|
|
98/NT/2000 interface, get it from
|
|
<ulink url="http://www.qvwm.org">
|
|
"http://www.qvwm.org"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
After starting vncserver, you can start the
|
|
<emphasis remap="bf">
|
|
vncviewer
|
|
</emphasis>
|
|
program on clients like MS Windows, Mac or Linux.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
See also the
|
|
<ulink url="http://www.dlhoffman.com/publiclibrary/RPM/X11_Window_Managers.html">
|
|
List of X11 Windows Managers
|
|
</ulink>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Compiling qvwm on Solaris :
|
|
</emphasis>
|
|
On Solaris you should install the following packages which you can get
|
|
from
|
|
<ulink url="http://sun.freeware.com">
|
|
"http://sun.freeware.com"
|
|
</ulink>
|
|
- xpm, imlib, jpeg, libungif, giflib (giftran), libpng, tiff. And you
|
|
can download the binary package for solaris from
|
|
<ulink url="http://www.qvwm.org">
|
|
"http://www.qvwm.org"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<para>
|
|
Or you can download the qvwm source for solaris from
|
|
<ulink url="http://www.qvwm.org">
|
|
"http://www.qvwm.org"
|
|
</ulink>
|
|
and compile it using gcc. If mainsite is busy use the mirror sites
|
|
listed there. Click on the link "The latest version of qvwm is
|
|
[ftp/http]" to download the source code.
|
|
</para>
|
|
<para>
|
|
Troubleshooting the compile:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
You must install all the packages listed - xpm, imlib, jpeg,
|
|
libungif, giflib, libpng, tiff. Otherwise src will not compile
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Must edit the src/util.cc file and change snprintf to printf to
|
|
compile the program to get rid of the compile errors.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
You should put unsigned long before arg in usleep()
|
|
usleep((unsigned long) 10000)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Still problems then see
|
|
<ulink url="http://www.milkywaygalaxy.freeservers.com/vnc">
|
|
"http://www.milkywaygalaxy.freeservers.com/vnc"
|
|
</ulink>
|
|
for compile instructions.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
For transferring files from Unix to MS Windows use the ftp clients like
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Commercial :
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
The ftp voyager
|
|
<ulink url="http://cws.internet.com/ftp-ftpvoyag.html">
|
|
"http://cws.internet.com/ftp-ftpvoyag.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Cute ftp
|
|
<ulink url="http://cws.internet.com/ftp-cuteftp.html">
|
|
"http://cws.internet.com/ftp-cuteftp.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Free ratings:
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
WSFTP :
|
|
<ulink url="http://www.csra.net/junodj/ws_ftp32.htm">
|
|
"http://www.csra.net/junodj/ws_ftp32.htm"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
LeechFTP
|
|
<ulink url="http://cws.internet.com/ftp-leechftp.html">
|
|
"http://cws.internet.com/ftp-leechftp.html"
|
|
</ulink>
|
|
<ulink url="http://stud.fh-heilbronn.de/~jdebis/leechftp/">
|
|
"http://stud.fh-heilbronn.de/~jdebis/leechftp/"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
FTP Control
|
|
<ulink url="http://cws.internet.com/ftp-ftpcontrol.html">
|
|
"http://cws.internet.com/ftp-ftpcontrol.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
GetRight
|
|
<ulink url="http://cws.internet.com/ftp-getright.html">
|
|
"http://cws.internet.com/ftp-getright.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="vi_companions">
|
|
<title>
|
|
Vi companions
|
|
</title>
|
|
<para>
|
|
Generally Vim is used in conjunction with other powerful tools like
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
and
|
|
<emphasis remap="bf">
|
|
gdb
|
|
</emphasis>
|
|
.
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
is for very rapid navigation through millions of lines of "C/C++" code
|
|
and
|
|
<emphasis remap="bf">
|
|
gdb
|
|
</emphasis>
|
|
is for debugging the "C/C++" code. A brief introduction of these two
|
|
indispensable commands will be given in this chapter.
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
is the most powerful command available for coding C, C++, Java, Perl,
|
|
Korn/Bourne shell scripts or Fortran. Developers very extensively use
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
to navigate through thousands of functions within C/C++ programs. See
|
|
'man ctags' on Unix. It is
|
|
<emphasis remap="bf">
|
|
very important
|
|
</emphasis>
|
|
that you learn how to use ctags to develop programs in C or C++, Java,
|
|
etc.. Navigation is the single most important task while doing
|
|
development of C or C++ code. Using ctags you can very quickly read the
|
|
code by jumping from a calling line to the called function, drill down
|
|
deeper into nested function calls, and unwind back all the way up to the
|
|
top. You can go back and forth from function to function very quickly.
|
|
</para>
|
|
<para>
|
|
Without NAVIGATION you will be completely lost!
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
is like the magnetic COMPASS needle for the programmers.
|
|
</para>
|
|
<para>
|
|
Usage of
|
|
<emphasis remap="bf">
|
|
ctags
|
|
</emphasis>
|
|
:
|
|
<programlisting format="linespecific">
|
|
ctags *.cpp
|
|
gvim -t foo_function
|
|
gvim -t main</programlisting>
|
|
This will edit the C++ program file which contains the function
|
|
foo_function() and will automatically place the cursor on the first line
|
|
of the function foo_function(). The second command takes you to the line
|
|
with the main() function definition.
|
|
</para>
|
|
<para>
|
|
Inside the Vim editor, you can jump to a function by typing : (colon)
|
|
tag < function name > as below -
|
|
<programlisting format="linespecific">
|
|
:tag sample_function</programlisting>
|
|
This will place the cursor on first line of sample_function()
|
|
</para>
|
|
<para>
|
|
If you want to jump into the function from a line in file which contains
|
|
the function name, place the cursor just before the function name and
|
|
press
|
|
<emphasis remap="bf">
|
|
CTRL+]
|
|
</emphasis>
|
|
(press control key and left-square-bracket key simultaneously).
|
|
<programlisting format="linespecific">
|
|
// example code
|
|
switch(id_number) {
|
|
Case 1:
|
|
if ( foo_function( 22, "abcef") == 3 )
|
|
^
|
|
|
|
|
|
|
|
|
|
|
Place the cursor here (just before foo_function) and press CTRL+]
|
|
This takes you to the function named "foo_function".
|
|
To come back to this line press CTRL+t</programlisting>
|
|
To go back to the calling line press
|
|
<emphasis remap="bf">
|
|
CTRL+t
|
|
</emphasis>
|
|
(Control key and letter 't' together). Keep pressing
|
|
<emphasis remap="bf">
|
|
CTRL+t
|
|
</emphasis>
|
|
to unwind and go to the first line where you started the navigation.
|
|
That is you can keep pressing
|
|
<emphasis remap="bf">
|
|
CTRL+]
|
|
</emphasis>
|
|
and then keep pressing
|
|
<emphasis remap="bf">
|
|
CTRL+t
|
|
</emphasis>
|
|
to go back. You can repeat these as many times as you want to have
|
|
complete navigation through all the functions of C or C++.
|
|
</para>
|
|
<sect2 id="directory_tree">
|
|
<title>
|
|
Directory Tree 'tags'
|
|
</title>
|
|
<para>
|
|
To recursively process the tags file for the entire directory :
|
|
<programlisting format="linespecific">
|
|
$ cd $HOME
|
|
$ ctags -R</programlisting>
|
|
This will recurse the directory underneath and create a tag file all
|
|
the files under the directory and beneath. But to use this tag file
|
|
you must set the following in the vim session or modify .gvimrc file
|
|
<programlisting format="linespecific">
|
|
$ vi ~/.gvimrc
|
|
" Set the tag file search order
|
|
set tags=./tags,tags,~/tags,/home/john/ccplus/tags</programlisting>
|
|
</para>
|
|
<para>
|
|
Or in the Vim session you set the tags with colon command:
|
|
<programlisting format="linespecific">
|
|
$ vi somefile.cpp
|
|
:set tags=./tags,tags,~/tags,/home/john/ccplus/tags</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="ctags_esql">
|
|
<title>
|
|
Ctags for ESQL
|
|
</title>
|
|
<para>
|
|
Since ctags does not directly support the Embedded SQL/C (ESQL)
|
|
language, the following shell script can be used to create tags for
|
|
esql. ESQL/C is database SQL commands embedded inside the "C"
|
|
programs. Oracle's ESQL/C is called Pro*C and Sybase, Informix have
|
|
ESQL/C and PostgreSQL has product "ecpg".
|
|
</para>
|
|
<para>
|
|
Save this file as "sqltags.sh" and do chmod a+rx tags_gen.sh.
|
|
<programlisting format="linespecific">
|
|
#!/bin/sh
|
|
# Program to create ctags for ESQL, C++ and C files
|
|
ESQL_EXTN=pc
|
|
tag_file1=tags_file.1
|
|
tag_file2=tags_file.2
|
|
which_tag=ctags
|
|
rm -f $tag_file1 $tag_file2 tags
|
|
aa=`ls *.$ESQL_EXTN`
|
|
#echo $aa
|
|
for ii in $aa
|
|
do
|
|
#echo $ii
|
|
jj=`echo $ii | cut -d'.' -f1`
|
|
#echo $jj
|
|
if [ ! -f $jj.cpp ]; then
|
|
echo " "
|
|
echo " "
|
|
echo "***********************************************"
|
|
echo "ESQL *.cpp files does not exist.. "
|
|
echo "You must generate the *.cpp from *.pc file"
|
|
echo "using the Oracle Pro*C pre-compiler or Sybase"
|
|
echo "or Informix esql/c pre-compiler."
|
|
echo "And then re-run this command"
|
|
echo "***********************************************"
|
|
echo " "
|
|
exit
|
|
fi
|
|
rm -f tags
|
|
$which_tag $jj.cpp
|
|
kk=s/$jj\.cpp/$jj\.pc/g
|
|
#echo $kk > sed.tmp
|
|
#sed -f sed.tmp tags >> $tag_file1
|
|
#sed -e's/sample\.cpp/sample\.pc/g' tags >> $tag_file1
|
|
sed -e $kk tags >> $tag_file1
|
|
done
|
|
# Now handle all the C++/C files - exclude the ESQL *.cpp files
|
|
rm -f tags $tag_file2
|
|
bb=`ls *.cpp *.c`
|
|
aa=`ls *.$ESQL_EXTN`
|
|
for mm in $bb
|
|
do
|
|
ee=`echo $mm | cut -d'.' -f1`
|
|
file_type="NOT_ESQL"
|
|
# Exclude the ESQL *.cpp and *.c files
|
|
for nn in $aa
|
|
do
|
|
dd=`echo $nn | cut -d'.' -f1`
|
|
if [ "$dd" = "$ee" ]; then
|
|
file_type="ESQL"
|
|
break
|
|
fi
|
|
done
|
|
if [ "$file_type" = "ESQL" ]; then
|
|
continue
|
|
fi
|
|
rm -f tags
|
|
$which_tag $mm
|
|
cat tags >> $tag_file2
|
|
done
|
|
mv -f $tag_file2 tags
|
|
cat $tag_file1 >> tags
|
|
rm -f $tag_file1
|
|
# Must sort tags file for it work properly ....
|
|
sort tags > $tag_file1
|
|
mv $tag_file1 tags</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="ctags_javascript">
|
|
<title>
|
|
Ctags for JavaScript programs, Korn, Bourne shells
|
|
</title>
|
|
<para>
|
|
The shell script given below can be used to generate tags for a very
|
|
large variety of programs written in JavaScript, PHP/FI scripts, Korn
|
|
shell, C shell, Bourne shell and many others. This is a very generic
|
|
module.
|
|
</para>
|
|
<para>
|
|
Save this file as tags_gen.sh and do chmod a+rx tags_gen.sh.
|
|
<programlisting format="linespecific">
|
|
#!/bin/sh
|
|
tmp_tag=tags_file
|
|
tmp_tag2=tags_file2
|
|
echo " "
|
|
echo " "
|
|
echo " "
|
|
echo " "
|
|
echo " "
|
|
echo "Generate tags for ...."
|
|
while :
|
|
do
|
|
echo " Enter file extension for which you want to generate tags."
|
|
echo -n " File-extension should be like sh, js, ksh, etc... : "
|
|
read ans
|
|
if [ "$ans" == "" ]; then
|
|
echo " "
|
|
echo "Wrong entry. Try again!"
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
\rm -f $tmp_tag
|
|
aa=`ls *.$ans`
|
|
for ii in $aa
|
|
do
|
|
jj=`echo $ii | cut -d'.' -f1`
|
|
#echo $jj
|
|
cp $ii $jj.c
|
|
ctags $jj.c
|
|
echo "s/$jj.c/$ii/g" > $tmp_tag2
|
|
sed -f $tmp_tag2 tags >> $tmp_tag
|
|
\rm -f tags $jj.c
|
|
done
|
|
sort $tmp_tag > tags
|
|
\rm -f $tmp_tag $tmp_tag2</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="debugger_gdb">
|
|
<title>
|
|
Debugger gdb
|
|
</title>
|
|
<para>
|
|
You would be using gdb extensively along with Vi. Debugging is the
|
|
most important aspect of programming as the major cost of software
|
|
projects goes into debugging and testing.
|
|
</para>
|
|
<para>
|
|
To debug C++/C programs use 'gdb' tool. See
|
|
<emphasis remap="bf">
|
|
'man gdb'
|
|
</emphasis>
|
|
. You must compile your programs with -g3 option like
|
|
<screen format="linespecific">
|
|
gcc -g3 foo.c foo_another.c sample.c
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
To set up easy aliases do -
|
|
<screen format="linespecific">
|
|
Setup an alias in your ~/.bash_profile alias gdb='gdb
|
|
-directory=/home/src -directory=/usr/myname/src ' Give - gdb foo.cpp
|
|
gdb> dir /hom2/another_src This will add to file search path
|
|
gdb> break 'some_class::func<TAB><TAB> This will
|
|
complete the function name saving you typing time... and will output
|
|
like - gdb> break 'some_class::function_foo_some_where(int aa,
|
|
float bb)'
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
Pressing TAB key twice is the command line completion, which will save
|
|
you lots of typing time. This is one of the most important technique
|
|
of using gdb.
|
|
</para>
|
|
<para>
|
|
To get online help do -
|
|
<screen format="linespecific">
|
|
gdb> help Gives online help gdb> help breakpoints Gives more
|
|
details about breakpoints.
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
To set breakpoints and do debugging
|
|
<screen format="linespecific">
|
|
unixprompt> gdb exe_filename gdb> b main This will put
|
|
breakpoint in main() function gdb> b 123 This will put breakpoint
|
|
in line 123 of the current file gdb> help breakpoints Gives more
|
|
details about breakpoints.
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
To analyze the core dumps do
|
|
<screen format="linespecific">
|
|
unixprompt> gdb exe_filename core gdb> bt Gives backtrace of
|
|
functions and line numbers where the program failed gdb> help
|
|
backtrace Gives more details about backtrace.
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
You can also use GUI version of gdb called xxgdb.
|
|
</para>
|
|
<para>
|
|
See also gdb interface to Vim at
|
|
<ulink url="http://www.lxlinux.com/gdbvim.tgz">
|
|
"http://www.lxlinux.com/gdbvim.tgz"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<para>
|
|
Memory leak tools -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Freeware Electric Fence on linux cd,
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Commercial tools Purify
|
|
<ulink url="http://www.rational.com">
|
|
"http://www.rational.com"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Insure++
|
|
<ulink url="http://www.insure.com">
|
|
"http://www.insure.com"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="vim_help">
|
|
<title>
|
|
Online VIM help
|
|
</title>
|
|
<para>
|
|
See the online man pages. At unix shell prompt type
|
|
<emphasis remap="bf">
|
|
'man vim'
|
|
</emphasis>
|
|
and
|
|
<emphasis remap="bf">
|
|
'man gvim'
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
<para>
|
|
Or inside the gvim session type :help to get the help page. See also
|
|
<xref linkend="vim-tutorial"/>
|
|
To see the settings type :set all or :set. To see list of options type
|
|
:options. To see topics on set type :help set.
|
|
</para>
|
|
<para>
|
|
<screen format="linespecific">
|
|
VIM - main help file Move around: Use the cursor keys, or "h" to go
|
|
left, "j" to go down, "k" to go up, "l" to go right. ":1" takes you to
|
|
1st line of page ":n" takes you to nth line of page "<SHIFT>g"
|
|
takes you to bottom of page ":/someword/ will search for "someword" in
|
|
doc Close this window: Use ":q<Enter>". Jump to a subject:
|
|
Position the cursor on a tag between |bars| and hit CTRL-]. With the
|
|
mouse: ":set mouse=a" to enable the mouse (in xterm or GUI).
|
|
Double-click the left mouse button on a tag between |bars|. jump back:
|
|
Type CTRL-T or CTRL-O. Get specific help: It is possible to go
|
|
directly to whatever you want help on, by giving an argument to the
|
|
":help" command |:help|. It is possible to further specify the
|
|
context: WHAT PREPEND EXAMPLE ~ Normal mode commands (nothing) :help x
|
|
Visual mode commands v_ :help v_u Insert mode commands i_ :help
|
|
i_<Esc> command-line commands : :help :quit command-line editing
|
|
c_ :help c_<Del> Vim command arguments - :help -r options '
|
|
:help 'textwidth' list of documentation files: |howto.txt| how to do
|
|
the most common things |intro.txt| introduction to Vim |index.txt|
|
|
alphabetical index for each mode |autocmd.txt| automatically executing
|
|
commands on an event |change.txt| delete and replace text
|
|
</screen>
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="vim_homepage">
|
|
<title>
|
|
Vim Home page and Vim links
|
|
</title>
|
|
<para>
|
|
The home page of vim is at
|
|
<ulink url="http://www.vim.org">
|
|
"http://www.vim.org"
|
|
</ulink>
|
|
and mirror site in US is at
|
|
<ulink url="http://www.us.vim.org">
|
|
"http://www.us.vim.org"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Vim FAQ is at
|
|
<ulink url="http://www.grafnetix.com/~laurent/vim/faq.html">
|
|
"http://www.grafnetix.com/~laurent/vim/faq.html"
|
|
</ulink>
|
|
and at
|
|
<ulink url="http://www.vim.org/faq">
|
|
"http://www.vim.org/faq"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Eli's Vim Page at
|
|
<ulink url="http://www.netusa.net/~eli/src/vim.html">
|
|
"http://www.netusa.net/~eli/src/vim.html"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Vi Lovers home page
|
|
<ulink url="http://www.thomer.com/thomer/vi/vi.html">
|
|
"http://www.thomer.com/thomer/vi/vi.html"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Vim Reference Guide at
|
|
<ulink url="http://scisun.sci.ccny.cuny.edu/~olrcc/vim/">
|
|
"http://scisun.sci.ccny.cuny.edu/~olrcc/vim/"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Vim mailing list at
|
|
<ulink url="http://www.findmail.com/listsaver/vimannounce.html">
|
|
"http://www.findmail.com/listsaver/vimannounce.html"
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.vim.org/mail.html">
|
|
"http://www.vim.org/mail.html"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Mailing list archives are kept at:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.egroups.com/group/vim">
|
|
"http://www.egroups.com/group/vim"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.egroups.com/group/vimdev">
|
|
"http://www.egroups.com/group/vimdev"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.egroups.com/group/vimannounce">
|
|
"http://www.egroups.com/group/vimannounce"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
Vim macros
|
|
<ulink url="http://www.grafnetix.com/~laurent/vim/macros.html">
|
|
"http://www.grafnetix.com/~laurent/vim/macros.html"
|
|
</ulink>
|
|
</para>
|
|
<sect2 id="vi_resources">
|
|
<title>
|
|
Vi Resources and Tips
|
|
</title>
|
|
<para>
|
|
The following Vi resources are available on internet:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
O'Reilly "Learning the Vi Editor" at
|
|
<ulink url="http://www.eyetap.org/ece385/oreilly/unix/vi/index.htm">
|
|
"http://www.eyetap.org/ece385/oreilly/unix/vi/index.htm"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vi Google directory at
|
|
<ulink url="http://directory.google.com/Top/Computers/Software/Editors/Vi/?tc=1">
|
|
Google-Vi
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Resources, Tips, News about Vim
|
|
<ulink url="http://vim.sourceforge.net">
|
|
"http://vim.sourceforge.net"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vi Cheatsheet
|
|
<ulink url="http://www.geekcheat.com/Merchant2/merchant.mv">
|
|
"http://www.geekcheat.com/Merchant2/merchant.mv"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vim and vi article
|
|
<ulink url="http://www.troubleshooters.com/lpm/200212/200212.htm">
|
|
"http://www.troubleshooters.com/lpm/200212/200212.htm"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vim Outliner - An outline processor is a software program
|
|
enabling the user to quickly construct outlines, and better yet,
|
|
to correct and rearrange the outline.
|
|
<ulink url="http://www.troubleshooters.com/vimoutliner">
|
|
"http://www.troubleshooters.com/vimoutliner"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="vim-tutorial">
|
|
<title>
|
|
Vim Tutorial
|
|
</title>
|
|
<sect2 id="vimhandson">
|
|
<title>
|
|
Vim Hands-on Tutorial
|
|
</title>
|
|
<para>
|
|
On Linux system see the tutorial at /usr/doc/vim-common-5.*/tutor, on
|
|
other unix systems go to directory where vim is installed and look for
|
|
doc directory.
|
|
<programlisting format="linespecific">
|
|
bash$ cd /usr/doc/vim-common*/tutor
|
|
bash$ less README.txt
|
|
bash$ cp tutor $HOME
|
|
bash$ cd $HOME
|
|
bash$ less tutor</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vimurls">
|
|
<title>
|
|
Vi Tutorials on Internet
|
|
</title>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Purdue University
|
|
<ulink url="http://ecn.www.ecn.purdue.edu/ECN/Documents/VI/">
|
|
"http://ecn.www.ecn.purdue.edu/ECN/Documents/VI/"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Advanced Vi tutorial
|
|
<ulink url="http://www.yggdrasil.com/bible/bible-src/user-alpha-4/guide/node171.html">
|
|
"http://www.yggdrasil.com/bible/bible-src/user-alpha-4/guide/node171.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Tutorials
|
|
<ulink url="http://www.cfm.brown.edu/Unixhelp/vi_.html">
|
|
"http://www.cfm.brown.edu/Unixhelp/vi_.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Univ of Hawaii tutorial
|
|
<ulink url="http://www.eng.hawaii.edu/Tutor/vi.html">
|
|
"http://www.eng.hawaii.edu/Tutor/vi.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
InfoBound
|
|
<ulink url="http://www.infobound.com/vi.html">
|
|
"http://www.infobound.com/vi.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Vi Lovers home page
|
|
<ulink url="http://www.thomer.com/thomer/vi/vi.html">
|
|
"http://www.thomer.com/thomer/vi/vi.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
vi Help file
|
|
<ulink url="http://www.vmunix.com/~gabor/vi.html">
|
|
"http://www.vmunix.com/~gabor/vi.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
These are dead links::
|
|
</para>
|
|
<para>
|
|
Quick Vi tutorial
|
|
<ulink url="http://linuxwww.db.erau.edu/LUG/node165.html">
|
|
"http://linuxwww.db.erau.edu/LUG/node165.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Tutorials
|
|
<ulink url="http://www.linuxbox.com/~taylor/4ltrwrd/section3_4.html">
|
|
"http://www.linuxbox.com/~taylor/4ltrwrd/section3_4.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Unix world online vi tutorial
|
|
<ulink url="http://www.networkcomputing.com/unixworld/unixhome.html">
|
|
"http://www.networkcomputing.com/unixworld/unixhome.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Cornell Univ
|
|
<ulink url="http://www.tc.cornell.edu/Edu/Tutor/Basics/vi/">
|
|
"http://www.tc.cornell.edu/Edu/Tutor/Basics/vi/"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Beginner's Guide to vi
|
|
<ulink url="http://www.cs.umr.edu/unixinfo/general/packages/viguide.html">
|
|
"http://www.cs.umr.edu/unixinfo/general/packages/viguide.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
vim FAQ
|
|
<ulink url="http://www.math.fu-berlin.de/~guckes/vim/faq/">
|
|
"http://www.math.fu-berlin.de/~guckes/vim/faq/"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
There are many Vi Tutorials on internet. In Yahoo (Lycos, excite or
|
|
Hotbot) enter "Vi Tutorial" in search field and search engine will
|
|
return many pointers.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="vimtut">
|
|
<title>
|
|
Vi Tutorial
|
|
</title>
|
|
<para>
|
|
In this tutorial, we describe some "advanced"
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
concepts and commands, so you can appreciate the power of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
and so you decide how to build your knowledge of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
commands. Nearly all
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
references list the available commands, but many don't bother to discuss
|
|
how the commands interrelate; this topic is the main purpose of this
|
|
tutorial.
|
|
</para>
|
|
<sect2 id="cursor_movement">
|
|
<title>
|
|
Cursor Movement Commands
|
|
</title>
|
|
<para>
|
|
The
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
cursor movement commands allow you to position the cursor in the file
|
|
and/or on the screen efficiently, with a minimum number of keystrokes.
|
|
There are oodles of cursor movement commands - don't try memorizing
|
|
them all at once! Later, we'll see that much of the power of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
comes from mixing cursor movement commands with other commands to
|
|
delete, change, yank (copy), and filter text.
|
|
</para>
|
|
<para>
|
|
Please edit a large text file (say,
|
|
<emphasis remap="bf">
|
|
wknight
|
|
</emphasis>
|
|
) so you can experiment with each command as it is described. Keep in
|
|
mind these commands will only work in Command Mode, not Insert Mode;
|
|
if you start getting your "commands" in your text, press the ESC key
|
|
to return to Command Mode.
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
cursor keys
|
|
</emphasis>
|
|
: As we've seen, cursor keys move by single character amounts
|
|
left, down, up, and right. Movement above the top of the file,
|
|
below the bottom, to the right of the end of a line, or left of
|
|
the beginning is not allowed (no line wrapping).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
hjkl
|
|
</emphasis>
|
|
: When
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
was written (around 1978), many terminals on UNIX systems did
|
|
not have cursor keys!
|
|
<emphasis remap="bf">
|
|
h, j, k,
|
|
</emphasis>
|
|
and
|
|
<emphasis remap="bf">
|
|
l
|
|
</emphasis>
|
|
were chosen as commands to move left, down, up, and right,
|
|
respectively. Try them! Most
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
diehards prefer these to the cursor keys because
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
(a)
|
|
</emphasis>
|
|
they are in the same place on all keyborads, and
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
(b)
|
|
</emphasis>
|
|
they fit nicely under the fingers, unlike most cursor
|
|
keys, which are arranged in a box or "T" or some other
|
|
nonlinear shape.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
Why h, j, k, and l? Well, in the ASCII character set, CTRL-H is
|
|
backspace (moves left), CTRL-J is linefeed (moves down), and, of
|
|
course, k and l are next to h and j, so you see, they're
|
|
mnemonic.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
0
|
|
</emphasis>
|
|
: ("zero", not "oh") Move to the beginning of current line. (To
|
|
try this and the next few commands, use the cursor keys or
|
|
<emphasis remap="bf">
|
|
h j k l
|
|
</emphasis>
|
|
to move to an indented text line that contains few "e"
|
|
characters. If you can't find an indented line in your file,
|
|
create one by inserting a few space characters at the beginning
|
|
of a line.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
^
|
|
</emphasis>
|
|
: Move to first non-white character of current line. (For
|
|
indented line, 0 and ^ are different.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
$
|
|
</emphasis>
|
|
: Move to last character of current line.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
tC
|
|
</emphasis>
|
|
: Move to (but not on) next character c in current line. (Press
|
|
0, then press te. This will move to the first e in the curent
|
|
line.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
fC
|
|
</emphasis>
|
|
: Find (move on top of) next character c in current line. (Press
|
|
fe, and the cursor will find - that is, move on top - the next e
|
|
in the current line.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
TC
|
|
</emphasis>
|
|
: Move to (but not on) the previous character c in current line
|
|
(Press $, then Te.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
FC
|
|
</emphasis>
|
|
: Find (move on top of) the previous character c in current
|
|
line. (Press Fe.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
n|
|
|
</emphasis>
|
|
: Move to column n in current line. (Try 20 |. The digits 2 and
|
|
0 will not be displayed as you type them, but when you press |
|
|
the cursor will move to column 20.) Try some experiments with t
|
|
f T F | . When you do something illegal,
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
will beep your terminal.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
w
|
|
</emphasis>
|
|
: Forward to beginning of next "small" word ( a "small" word
|
|
consists of unbroken alphanumeric characters or punctuation
|
|
characters, but not mixed alphanumeric and punctuation). Try
|
|
tapping w a dozen times or so - note what happens at
|
|
punctuation.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
W
|
|
</emphasis>
|
|
: Forward to beginning of next "big" word (alphanumeric and
|
|
punctuation mixed). Try W a dozen times or so.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
b
|
|
</emphasis>
|
|
: Backward to beginning of "small" word.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
B
|
|
</emphasis>
|
|
: Backward to beginning of "big" word.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
e
|
|
</emphasis>
|
|
: Forward to end of "small" word.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
E
|
|
</emphasis>
|
|
: Forward to end of "big" word.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
+ Return
|
|
</emphasis>
|
|
: Move to first non-white space character on next line. (+ and
|
|
the Return key have the same effect.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
-
|
|
</emphasis>
|
|
: Move to first non-white space character on previous line.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
)
|
|
</emphasis>
|
|
: Move to the end of sentence. (A sentence ends either at a
|
|
blank line or at a period or examination mark followed by two
|
|
space characters or at the end of a line. A period or
|
|
exclamation mark followed by one space character does not end a
|
|
sentence; this is correct behaviour, according to traditional
|
|
rules of how sentences should appear in typed documents, but
|
|
often appears wrong to those who have never suffered through a
|
|
formal typing class.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
(
|
|
</emphasis>
|
|
: Move to beginning of sentence.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
}
|
|
</emphasis>
|
|
: Move to end of paragraph. (Paragraphs are seperated with blank
|
|
lines, by
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
's definition.)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
{
|
|
</emphasis>
|
|
: Move to beginning of paragraph.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
H
|
|
</emphasis>
|
|
: Move to home position (top line) on the screen
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
M
|
|
</emphasis>
|
|
: Move to middle line on the screen.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
L
|
|
</emphasis>
|
|
: Move to last line on the screen.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
nG
|
|
</emphasis>
|
|
: Move to line n. If n is not given, move to the last line in
|
|
the file. (Try 15G to move to line 15, for example. The CTRL-G
|
|
command displays the name of the file, some status information,
|
|
and the current line number. To move to the top of the file: 1G)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-d
|
|
</emphasis>
|
|
: Scroll down half-screen (see note).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-u
|
|
</emphasis>
|
|
: Scroll up half-screen (see note).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-f
|
|
</emphasis>
|
|
: Move forward one-screen (see note).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-b
|
|
</emphasis>
|
|
: Move backward one-screen (see note).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Note
|
|
</emphasis>
|
|
: These four scrolling/paging commands cannot be used with the
|
|
delete, change, yank, or filter commands.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
/reg_exp
|
|
</emphasis>
|
|
: Move to next occurrence of the regular expression reg_exp When
|
|
you press /, the cursor drops to the lower left corner of the
|
|
screen and waits for you to type in the regular expression.
|
|
Press the Return key to finish;
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
then searches forward for the next occurrence of the regular
|
|
expression. For example, press /the followed by Return. This
|
|
moves forward to the next occurrence of the, perhaps imbedded in
|
|
the middle of some longer word (other, weather, etc.). If you
|
|
just press / and then Return,
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
searches for the next occurrence of whatever the last regular
|
|
expression was that you searched for.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
n
|
|
</emphasis>
|
|
: Has the same effect as pressing / and then Return; i.e.,
|
|
searches for the next occurrence of whatever the last regular
|
|
expression was that you searched for.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
?reg_exp
|
|
</emphasis>
|
|
: Searches backward, rather than forward. If no reg_exp is
|
|
given, it searches for the last regular expression that was
|
|
entered. Both / and ? wrap around, so searching "below" the
|
|
bottom or "above" the top of the file is legal.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
N
|
|
</emphasis>
|
|
: Same as pressing ? and then Return.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="repeat_counts">
|
|
<title>
|
|
Repeat Counts
|
|
</title>
|
|
<para>
|
|
Many of the movement commands discussed above can be preceded with a
|
|
repeat count; the movement is simply repeated the given number of
|
|
times:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
3w
|
|
</emphasis>
|
|
: Move forward three words
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
5k
|
|
</emphasis>
|
|
: Move up four characters
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
3fa
|
|
</emphasis>
|
|
: Find the third succeeding a in current line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
6+
|
|
</emphasis>
|
|
: Move down six lines
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
For some commands, the "repeat counts" has special meaning:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
4H
|
|
</emphasis>
|
|
: Move to Line 4 on the screen (home plus 3)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
8L
|
|
</emphasis>
|
|
: Move to the eigth line from the bottom of the screen
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
3$
|
|
</emphasis>
|
|
: Move to the end of the third line down
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
For some commands (e.g., ^) the repeat count is ignored; for others
|
|
(e.g., / and ? ) it is illegal
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="deleting_text">
|
|
<title>
|
|
Deleting Text
|
|
</title>
|
|
<para>
|
|
We've seen that
|
|
<emphasis remap="bf">
|
|
dd
|
|
</emphasis>
|
|
deletes the current line. This can be used with a repeat count: 3dd
|
|
deletes three lines, the current line, and the two following lines.
|
|
</para>
|
|
<para>
|
|
The d command can be used as a "prefix" on most of the movement
|
|
commands above to delete nearly arbitrary chunks of text. When used
|
|
with d, the movement commands are called target specifiers. d can be
|
|
given a repeat count. (As you try these experiments, remember to press
|
|
u after each command to undo the deletion).
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
dw
|
|
</emphasis>
|
|
: Delete "small" word forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d3w
|
|
</emphasis>
|
|
: Delete three "small" words forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
3dw
|
|
</emphasis>
|
|
: Three times, delete "small" word forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
3d3w
|
|
</emphasis>
|
|
: Three times, delete three "small" words forward (that is,
|
|
delete nine "small" words forward)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d+
|
|
</emphasis>
|
|
: Delete current line and next line down
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d/the
|
|
</emphasis>
|
|
: Delete from current character up to but not including the next
|
|
occurrence of the pattern the.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d$
|
|
</emphasis>
|
|
: Delete to end of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d0
|
|
</emphasis>
|
|
: Delete to beginning of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d30G
|
|
</emphasis>
|
|
: Delete from the curent line to and including Line 30
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
dG
|
|
</emphasis>
|
|
: Delete from current line to and including last line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d1G
|
|
</emphasis>
|
|
: Delete from current line to and including Line 1
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
To delete single characters, use x. x can be given a repeat count:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
15x
|
|
</emphasis>
|
|
: Delete current and 14 following characters
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
x is actually just an abbreviation of d1; that is, delete one
|
|
character right.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="changing_text">
|
|
<title>
|
|
Changing Text
|
|
</title>
|
|
<para>
|
|
The c command is similar to d, except it toggles
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
into Insert Mode, allowing the original (unwanted) text to be changed
|
|
to something else.
|
|
</para>
|
|
<para>
|
|
For example, put the cursor on the beginning of a word (press w to get
|
|
to the beginning of the next word). Then, press cw to change that
|
|
word. On the screen, the last character in the word being changed will
|
|
be replaced with a
|
|
<emphasis remap="bf">
|
|
$
|
|
</emphasis>
|
|
symbol indicating the boundary of the change; type in a new word (you
|
|
will overwrite the original word on the screen) and press the ESC key
|
|
when done. Your input may be longer or shorter than the word being
|
|
changed.
|
|
</para>
|
|
<para>
|
|
Put the cursor at the beginning of a line containing at least three
|
|
words, and try c3w to change three words. Try c$ to change to the end
|
|
of the current line. In all cases where the change affects only the
|
|
current line, the boundary of the change is indicated with $.
|
|
</para>
|
|
<para>
|
|
When a change affects more than just the current line,
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
deletes the original text from the screen and toggles into Insert
|
|
Mode. For example, try c3+ to change the current and the next three
|
|
lines;
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
deletes the four original lines from the screen and toggles into
|
|
Insert Mode in a new blank line. As usual, press the ESC key when you
|
|
have finished entering your new text.
|
|
</para>
|
|
<para>
|
|
Some other change commands:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
cc
|
|
</emphasis>
|
|
: Change current line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
5cc
|
|
</emphasis>
|
|
: Change five lines (current and next four)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
c/the
|
|
</emphasis>
|
|
: Change from current character up to but not including the next
|
|
occurrence of the pattern the
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
c$
|
|
</emphasis>
|
|
: Change to end of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
c30G
|
|
</emphasis>
|
|
: Change from the current line to and including Line 30
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
cG
|
|
</emphasis>
|
|
: Change from curernt line to and including last line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
c1G
|
|
</emphasis>
|
|
: Change from curernt line to and including Line 1
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="yanking_text">
|
|
<title>
|
|
Yanking (Copying) Text
|
|
</title>
|
|
<para>
|
|
The y command yanks a copy of text into a buffer; the yanked text can
|
|
then be put (or pasted) elsewhere in the file using p or P.
|
|
</para>
|
|
<para>
|
|
The simplest form of yank is yy to yank the current line; after yy,
|
|
try p to put a copy of the yanked line after the cursor. Following yy,
|
|
you can make as many copies of the yanked line as you want by moving
|
|
up and down in the file and pressing p.
|
|
</para>
|
|
<para>
|
|
To copy multiple lines, try, for example, 5yy (yank the current and
|
|
next four lines). p puts a copy of the yanked lines after the cursor;
|
|
the sequence 5yyp "works" but it probably doesn't do what you would
|
|
like. The P command is like p, but puts a copy of the yanked text
|
|
ahead of the cursor; try the sequence 5yyP.
|
|
</para>
|
|
<para>
|
|
Other yank commands:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
y3w
|
|
</emphasis>
|
|
: Yank three words
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
y$
|
|
</emphasis>
|
|
: Yank to end of current line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
y1G
|
|
</emphasis>
|
|
: Yank from current line to and including Line 1
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="filtering_text">
|
|
<title>
|
|
Filtering text
|
|
</title>
|
|
<para>
|
|
The filter command
|
|
<emphasis remap="bf">
|
|
!
|
|
</emphasis>
|
|
, prompts for the name of a UNIX command (which should be a filter),
|
|
then passes selected lines through the filter, replacing those
|
|
selected line in the
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
buffer with the output of the filter command.
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
's ability to pass nearly arbitrary chunks of text through any UNIX
|
|
filter adds incredible flexibility to
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
, at no "additional cost" in size or performance to
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
itself.
|
|
</para>
|
|
<para>
|
|
Some examples will help illustrate. Create a line in your file
|
|
containing just the word who and absolutely no other text. Put the
|
|
cursor on this line, and press
|
|
<emphasis remap="bf">
|
|
!!
|
|
</emphasis>
|
|
This command is analogous to dd, cc, or yy, but instead of deleting,
|
|
changing, or yanking the current line, it filters the current line.
|
|
When you press the second !, the cursor drops down to the lower left
|
|
corner of the screen and a single ! is displayed, prompting you to
|
|
enter the name of a filter. As the filter name, type sh and press the
|
|
Return key.
|
|
<emphasis remap="bf">
|
|
sh
|
|
</emphasis>
|
|
(the Bourne shell) is a filter! It reads standard input, does some
|
|
processing of its input (that is, executes commands), and sends its
|
|
output (the output of those commands) to standard output. Filtering
|
|
the line containing who through sh causes the line containing who to
|
|
be replaced with a list of the current users on the system - right in
|
|
your file!
|
|
</para>
|
|
<para>
|
|
Try repeating this process with
|
|
<emphasis remap="bf">
|
|
date
|
|
</emphasis>
|
|
. That is, create a line containing nothing but the word
|
|
<emphasis remap="bf">
|
|
date
|
|
</emphasis>
|
|
, then put the cursor on the line, and press
|
|
<emphasis remap="bf">
|
|
!!sh
|
|
</emphasis>
|
|
and the Return key. The line containing
|
|
<emphasis remap="bf">
|
|
date
|
|
</emphasis>
|
|
is replaced with the output of the
|
|
<emphasis remap="bf">
|
|
date
|
|
</emphasis>
|
|
command.
|
|
</para>
|
|
<para>
|
|
Put your cursor on the first line of the output of who. Count the
|
|
number of lines. Suppose, for example, the number is six. Then select
|
|
those six lines to be filtered through sort; press
|
|
<emphasis remap="bf">
|
|
6!!sort
|
|
</emphasis>
|
|
and the Return key. The six lines will be passed through sort, and
|
|
sort's output replaces the original six lines.
|
|
</para>
|
|
<para>
|
|
The filter command can only be used on complete lines, not on
|
|
characters or words.
|
|
</para>
|
|
<para>
|
|
Some other filter commands (here, < CR > means press Return):
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
!/the < CR > sort < CR >
|
|
</emphasis>
|
|
: Sort from the current line up to and including the next line
|
|
containing the
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
!1Ggrep the < CR >
|
|
</emphasis>
|
|
: Replace from the current line to and including Line 1 with
|
|
just the lines that contain the
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
!Gawk '{print $1}' < CR >
|
|
</emphasis>
|
|
: From the current line to the end of file, replace every line
|
|
with just its first word.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="marking_lines">
|
|
<title>
|
|
Marking Lines and Characters
|
|
</title>
|
|
<para>
|
|
You can mark lines and characters to be used as targest for movement,
|
|
deletion, change, yanking, and filtering using the command mc, where c
|
|
is a lowercase letter.
|
|
</para>
|
|
<para>
|
|
For example, put the cursor in the middle of some word and press ma.
|
|
This marks the character under the cursor as mark a.
|
|
</para>
|
|
<para>
|
|
Now, move the cursor off the marked character and to a different line
|
|
( use the cursor keys, CTRL-u, or whatever). To return to the marked
|
|
line, press 'a (that is, single quote, then a). This moves to the
|
|
first non-white space character on the line containing mark a.
|
|
</para>
|
|
<para>
|
|
Move off that line again. To return to the marked character, press `a
|
|
(that is, backquote, then a). This moves on top of the character
|
|
marked with a.
|
|
</para>
|
|
<para>
|
|
Marking is usually used with deleting, changing, yanking or filtering.
|
|
For example, move the cursor to a line other than the one containing
|
|
mark a, and then press d'a (d, single quote, a). This deletes from the
|
|
current line to and including the line marked with a.
|
|
</para>
|
|
<para>
|
|
Put the cursor in the middle of a different word and press mb to set
|
|
mark b. Now, move the cursor away from that word (but only a few
|
|
lines, so you can see what we're about to do more easily), and then
|
|
press d`b (d, backquote, b). This deletes from the current CHARACTER
|
|
to and including the CHARACTER marked with b.
|
|
</para>
|
|
<para>
|
|
As another example, to sort the output of who, mark the first line
|
|
(ma), then move the cursor to the last line and press !'asort and the
|
|
Return key.
|
|
</para>
|
|
<para>
|
|
If you jump to a mark and decide you want to jump back to whatever you
|
|
jumped from, you can press '' (jump back to line) or `` (jump back to
|
|
character).
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="naming_buffers">
|
|
<title>
|
|
Naming Buffers
|
|
</title>
|
|
<para>
|
|
When you delete, change, or yank text, the original text is stored
|
|
(until the next delete, change, or yank) in an unnamed buffer from
|
|
which it can be put using p or P. Using the unnamed buffer, only the
|
|
most recently deleted, changed or yanked text may be recovered.
|
|
</para>
|
|
<para>
|
|
If you wish to delete, change, or yank multiple sections of text and
|
|
remember them all (up to a maximum of 26), you can give a buffer name
|
|
ahead of the delete change or yank command. A buffer name has the form
|
|
"c (double quote, lowercase c).
|
|
</para>
|
|
<para>
|
|
For example, press "ayy to yank the current line into buffer a, then
|
|
move to a different line and press "byy to yank that line into buffer
|
|
b. Now, move elsewhere in the file and press "ap and "bp to put copies
|
|
of the text stored in buffers a and b.
|
|
</para>
|
|
<para>
|
|
Some other named buffer commands:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"a6yy
|
|
</emphasis>
|
|
: Yank six lines (current and next five) into buffer a
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"bd1G
|
|
</emphasis>
|
|
: Delete from the curernt line to and including Line 1, storing
|
|
the deleted lines in buffer b
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"cy'c
|
|
</emphasis>
|
|
: Yank from the current line to the line marked c into buffer c
|
|
(marks and buffers are distinct, and may have the same name
|
|
without confusing
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
)
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="substitutions">
|
|
<title>
|
|
Substitutions
|
|
</title>
|
|
<para>
|
|
To substitute one chunk of text for another in lines throughout your
|
|
file, use the :s command. Some substitute examples:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:1,$s/the/THE/g
|
|
</emphasis>
|
|
From Line 1 to the last line (line $), substitute for the text
|
|
THE; do this globally in each line where the occurrs
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:'a,.s/.*/ha ha/
|
|
</emphasis>
|
|
From the line marked a to the current line (line .), substitute
|
|
for everything on the line the text ha ha
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="misc_colon_commands">
|
|
<title>
|
|
Miscellaneous "Colon Commands"
|
|
</title>
|
|
<para>
|
|
All colon commands begin with a colon; when you press the colon, the
|
|
cursor drops to the lower left corner of the screen, and a colon
|
|
prompt is displayed waiting for you to finish your colon command.
|
|
</para>
|
|
<para>
|
|
Some important examples:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w
|
|
</emphasis>
|
|
Write the buffer contents to the file without quitting from
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w abc
|
|
</emphasis>
|
|
Write the buffer contents to the file abc (creating abc if it
|
|
doesn't exist, or overwriting current contents if it does exist)
|
|
without quitting from
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:1,10w abc
|
|
</emphasis>
|
|
Write lines 1 through 10 to file abc
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:'a,$w abc
|
|
</emphasis>
|
|
Write from the line marked a to the last line into file abc
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e abc
|
|
</emphasis>
|
|
Edit file abc, instead of the current file.
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
prints an error message if changes have been made to the curernt
|
|
file that have not been saved with :w
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e! abc
|
|
</emphasis>
|
|
Edit file abc, throwing away any changes that may have been made
|
|
to the current file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e #
|
|
</emphasis>
|
|
Edit the prior file edited (successive :e# commands toggle back
|
|
and forth between two files)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:f abc
|
|
</emphasis>
|
|
Change the file anme for the current
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
buffer to abc
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:q
|
|
</emphasis>
|
|
Quit, unless unsaved chanegs have been made
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:q!
|
|
</emphasis>
|
|
Quit, throwing away any changes that may have been made
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:r abc
|
|
</emphasis>
|
|
Read the file abc into current
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
buffer, after the line the cursor is on (try :r croc to read in
|
|
a copy of the croc file)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:!cmd
|
|
</emphasis>
|
|
Execute command cmd (who, sort, ls, etc.)
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="setting_options">
|
|
<title>
|
|
Setting Options
|
|
</title>
|
|
<para>
|
|
Various options affect the "feel" of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
. You can display all the various options that can be set using the
|
|
colon command :set all. You can also use set to change options.
|
|
</para>
|
|
<para>
|
|
For example, if you want to see line numbers for the lines in the file
|
|
you're editing, use the command :set number. To turn off line
|
|
numbering, use the command :set nonumber. Most options can be
|
|
abbreviated; :set nu turns on line numbering and :set nonu turns off
|
|
line numbering.
|
|
</para>
|
|
<para>
|
|
If you :set nomagic, the special meanings of regular expression
|
|
characters (period, asterisk, square bracket, etc.) are switched off.
|
|
Use :set magic to restore the special meanings.
|
|
</para>
|
|
<para>
|
|
Some options take a value. For example, :set tabstop=4 causes tabs to
|
|
be displayed as four space characters, rather than the usual eight.
|
|
</para>
|
|
<para>
|
|
If you find you always want certain options set certain ways, you can
|
|
put the set commands you want ina file .exrc, or you can set up the
|
|
environment variable EXINIT to specify the options you want.
|
|
</para>
|
|
<para>
|
|
For example, if your login shell is Bourne shell, this line could go
|
|
in your .profile file:
|
|
<programlisting format="linespecific">
|
|
EXINIT='set nomagic nu tabstop=4'; export EXINIT</programlisting>
|
|
If your login shell is a C shell, this line could go in your .login
|
|
file:
|
|
<programlisting format="linespecific">
|
|
setenv EXINIT 'set nomagic nu tabstop=4'</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="key_mappings">
|
|
<title>
|
|
Key Mappings
|
|
</title>
|
|
<para>
|
|
If you find you're performing a series of simple commands over and
|
|
over, you can map the command series to an unused command key using
|
|
the :map command. If your mapping must include control characters such
|
|
as Return key (CTRL-M in ASCII) or the ESC (CTRL-[ in ASCII) key,
|
|
precede such characters with CTRL-v to suppress their usual special
|
|
meaning.
|
|
</para>
|
|
<para>
|
|
For example, this command maps CTRL-A to move the cursor forward 55
|
|
lines, then back up to the most recent blank line, then change that
|
|
blank line to a formfeed (CTRL-L) and three blank lines. That is, each
|
|
CTRL-A will paginate the next page, without splitting paragraphs
|
|
across pages.
|
|
</para>
|
|
<para>
|
|
Note: In this command, each control character is shown as ^C, where C
|
|
is some uppercase letter. For example, CTRL-M is shown as ^M. Also,
|
|
when you enter this command you will not see the CTRL-v characters as
|
|
shown: each CTRL-v merely suppresses the usual special meaning of the
|
|
following control character, so when you press the sequence ^V^M, all
|
|
you will see on the screen is ^M. In this command, ^M is the Return
|
|
key and ^[ is the ESC key.
|
|
<programlisting format="linespecific">
|
|
:map ^A 55+?^$^V^Mcc^V^L^V^M^V^M^V^M^V^[</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="edit_multiple">
|
|
<title>
|
|
Editing Multiple Files
|
|
</title>
|
|
<para>
|
|
You can edit multiple files with
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
by giving multiple file names as command line arguments:
|
|
<programlisting format="linespecific">
|
|
vi croc fatherw wknight</programlisting>
|
|
Three colon commands are used to move through the multiple files:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:n
|
|
</emphasis>
|
|
Move to the next file in the argument list (you must save
|
|
changes with :w or
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
will print an error message)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:N
|
|
</emphasis>
|
|
Move to the previous file in the argument list (you must save
|
|
changes with :w or
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
will print an error message)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:rew
|
|
</emphasis>
|
|
Rewind and start over with the first file in the argument list
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
The :n, :N, and :rew commands are somewhat clumsy, but there are some
|
|
important benefits: the contents of named buffers ("a, "b, "c, etc.)
|
|
are remembered across files, so you can use :n and :rew with p and P
|
|
to copy text back and forth between files. Also, the most recent
|
|
search string for the / and ? commands remembered across files, so you
|
|
can do repetitive searches in multiple files rather easily.
|
|
</para>
|
|
<para>
|
|
For example, try the following experiment: First get out of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
, then execute
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
with croc and wknight as arguments:
|
|
<programlisting format="linespecific">
|
|
$ vi croc wknight</programlisting>
|
|
In croc, search for the
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
/the < CR >
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Yank this line into buffer a:
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"ayy
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Now go to the next file (you've made no change to croc, so this will
|
|
work):
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:n < CR >
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Search for the "next" line containing the, without retyping the search
|
|
string:
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
n
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Put a copy of buffer a after the current line in wknight:
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"ap
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Move down two lines, and yank the current line into buffer b:
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
jj"byy
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Save the changes to wknight
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w < CR >
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Now, rewind to croc
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:rew < CR >
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Search again, and put a copy of buffer b after the found line:
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
n"bp
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
Save the changes, and exit
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ZZ
|
|
</emphasis>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="final_remarks">
|
|
<title>
|
|
Final Remarks
|
|
</title>
|
|
<para>
|
|
This tutorial was intended to introduce some of the
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
capabilities that you might overlook in your system's
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
manual or that might not be mentioned in the manual (different systems
|
|
have manuals of widely varying quality).
|
|
</para>
|
|
<para>
|
|
You will not be a
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
expert after reading this tutorial, but you will have a good
|
|
appreciation of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
's capabilities. Only time and effort can make a
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
expert. But the efficiency and universality of
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
make this effort pay off in the long run.
|
|
</para>
|
|
<para>
|
|
You may have decided you hate
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
. So be it! But be aware that
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
remains the standard UNIX text editor - the one editor you can count
|
|
on being available on every UNIX system you'll use - so even if you
|
|
prefer to use something else day-to-day, you'd be well advised to know
|
|
the bare minimum
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
material covered in this tutorial.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="vimref">
|
|
<title>
|
|
Vim Reference Card
|
|
</title>
|
|
<sect2 id="vi_states">
|
|
<title>
|
|
Vi states
|
|
</title>
|
|
<para>
|
|
Vi has 3 modes:
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
command mode
|
|
</emphasis>
|
|
</emphasis>
|
|
- Normal and initial state; others return here (use
|
|
<emphasis remap="bf">
|
|
ESC
|
|
</emphasis>
|
|
to abort a partially typed command)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
input mode
|
|
</emphasis>
|
|
</emphasis>
|
|
- entered by specific commands
|
|
<emphasis remap="bf">
|
|
a i A I o O c C s S R
|
|
</emphasis>
|
|
and ended by
|
|
<emphasis remap="bf">
|
|
ESC
|
|
</emphasis>
|
|
or abnormally with interrupt
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
line mode
|
|
</emphasis>
|
|
</emphasis>
|
|
- i.e. waiting for input after a
|
|
<emphasis remap="bf">
|
|
:
|
|
</emphasis>
|
|
,
|
|
<emphasis remap="bf">
|
|
/
|
|
</emphasis>
|
|
,
|
|
<emphasis remap="bf">
|
|
?
|
|
</emphasis>
|
|
or a
|
|
<emphasis remap="bf">
|
|
!
|
|
</emphasis>
|
|
command (end with
|
|
<emphasis remap="bf">
|
|
CR
|
|
</emphasis>
|
|
, abort with
|
|
<emphasis remap="bf">
|
|
CTRL-c
|
|
</emphasis>
|
|
).
|
|
<emphasis remap="bf">
|
|
CTRL
|
|
</emphasis>
|
|
is the control key:
|
|
<emphasis remap="bf">
|
|
CTRL-c
|
|
</emphasis>
|
|
means "control c"
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="shell_commands">
|
|
<title>
|
|
Shell Commands
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
TERM=
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
code
|
|
</emphasis>
|
|
Puts a code name for your terminal into the variable
|
|
<emphasis remap="bf">
|
|
TERM
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
export TERM
|
|
</emphasis>
|
|
Conveys the value of
|
|
<emphasis remap="bf">
|
|
TERM
|
|
</emphasis>
|
|
(the terminal code) to any UNIX system program that is terminal
|
|
dependant.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
tput init
|
|
</emphasis>
|
|
Initializes the terminal so that it will function properly with
|
|
various UNIX system programs.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
filename
|
|
</emphasis>
|
|
Accesses the
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
screen editor so that you can edit a specified file.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
file1 file2 file3
|
|
</emphasis>
|
|
Enters three files into the
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
buffer to be edited. Those files are
|
|
<emphasis remap="it">
|
|
file1, file2,
|
|
</emphasis>
|
|
and
|
|
<emphasis remap="it">
|
|
file3
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
view
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
Invoke vi editor on
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
in read-only mode
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
vi -R
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
Invoke vi editor on
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
in read-only mode
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
vi -r
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
Recover
|
|
<emphasis remap="it">
|
|
file
|
|
</emphasis>
|
|
and recent edits after system crash
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="setting_option">
|
|
<title>
|
|
Setting Options
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
Activate
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
option=value
|
|
</emphasis>
|
|
Assign
|
|
<emphasis remap="it">
|
|
value
|
|
</emphasis>
|
|
to
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set no
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
Deactivate
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set
|
|
</emphasis>
|
|
Display options set by user
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set all
|
|
</emphasis>
|
|
Display list of all current options, both default and those set
|
|
by the user
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
? Display values of
|
|
<emphasis remap="it">
|
|
option
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="notations_used">
|
|
<title>
|
|
Notations used
|
|
</title>
|
|
<para>
|
|
Notations:
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-c
|
|
</emphasis>
|
|
<emphasis remap="bf">
|
|
CTRL
|
|
</emphasis>
|
|
is the control key:
|
|
<emphasis remap="bf">
|
|
CTRL-c
|
|
</emphasis>
|
|
means "control c"
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CR
|
|
</emphasis>
|
|
is Carriage return (ENTER key)
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="interrupting">
|
|
<title>
|
|
Interrupting, cancelling
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ESC
|
|
</emphasis>
|
|
end insert or incomplete command
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-?
|
|
</emphasis>
|
|
<emphasis remap="bf">
|
|
CTRL
|
|
</emphasis>
|
|
is the control key:
|
|
<emphasis remap="bf">
|
|
CTRL-?
|
|
</emphasis>
|
|
means "control ?" delete or rubout interrupts
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-l
|
|
</emphasis>
|
|
reprint/refresh screen if CTRL-? scrambles it
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="file_manipulation">
|
|
<title>
|
|
File Manipulation
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ZZ
|
|
</emphasis>
|
|
Save the file and exit vi
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:wq
|
|
</emphasis>
|
|
Save the file and exit vi
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w
|
|
</emphasis>
|
|
Write the current file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w!
|
|
</emphasis>
|
|
Force write the current file, if file is read-only
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:w
|
|
<emphasis remap="it">
|
|
name
|
|
</emphasis>
|
|
</emphasis>
|
|
Write to file
|
|
<emphasis remap="it">
|
|
name
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:q
|
|
</emphasis>
|
|
Exit from vi
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:q!
|
|
</emphasis>
|
|
Force exit from vi (discarding changes)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e name
|
|
</emphasis>
|
|
Edit file
|
|
<emphasis remap="it">
|
|
name
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e!
|
|
</emphasis>
|
|
reedit, discard changes
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e + name
|
|
</emphasis>
|
|
edit file
|
|
<emphasis remap="it">
|
|
name
|
|
</emphasis>
|
|
, starting at end
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e + n
|
|
</emphasis>
|
|
edit starting at line
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:e #
|
|
</emphasis>
|
|
edit alternate file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:n
|
|
</emphasis>
|
|
edit next file in
|
|
<emphasis remap="it">
|
|
arglist
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:args
|
|
</emphasis>
|
|
list files in current filelist
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:rew
|
|
</emphasis>
|
|
rewind current filelist and edit first file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:n args
|
|
</emphasis>
|
|
specify new arglist
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:f
|
|
</emphasis>
|
|
show current file and line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-G
|
|
</emphasis>
|
|
synonym for :f , show current file and line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:ta tag
|
|
</emphasis>
|
|
to tag file entry
|
|
<emphasis remap="it">
|
|
tag
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-]
|
|
</emphasis>
|
|
:ta, following word is tag
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="movement">
|
|
<title>
|
|
Movement
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Arrows
|
|
</emphasis>
|
|
Move the cursor
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-d
|
|
</emphasis>
|
|
Scroll half page down
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-u
|
|
</emphasis>
|
|
Scroll half page up
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-f
|
|
</emphasis>
|
|
Scroll a full page down
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-b
|
|
</emphasis>
|
|
Scroll a full page up
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:0
|
|
</emphasis>
|
|
Move to start of file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:n
|
|
</emphasis>
|
|
Move to line number n
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:$
|
|
</emphasis>
|
|
Move to end of file
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
0
|
|
</emphasis>
|
|
Move to start of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
^
|
|
</emphasis>
|
|
Move to first non-blank character
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
$
|
|
</emphasis>
|
|
Move to end of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CR
|
|
</emphasis>
|
|
Move to the start of next line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
-
|
|
</emphasis>
|
|
Move to the start of previous line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
%
|
|
</emphasis>
|
|
Find matching bracket
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
G
|
|
</emphasis>
|
|
goto line (last line default)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
]]
|
|
</emphasis>
|
|
next section/function
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
[[
|
|
</emphasis>
|
|
previous section/function
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="line_position">
|
|
<title>
|
|
Line Positioning
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
H
|
|
</emphasis>
|
|
Home window line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
L
|
|
</emphasis>
|
|
Last window line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
M
|
|
</emphasis>
|
|
Middle window line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
+
|
|
</emphasis>
|
|
Next line, at first non-white
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
-
|
|
</emphasis>
|
|
Previous line, at first non-white
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CR
|
|
</emphasis>
|
|
return, same as +
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
j
|
|
</emphasis>
|
|
next line, same column
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
k
|
|
</emphasis>
|
|
previous line, same column
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="charact_position">
|
|
<title>
|
|
Character positioning
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
0
|
|
</emphasis>
|
|
beginning of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
$
|
|
</emphasis>
|
|
end of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
h
|
|
</emphasis>
|
|
forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
l
|
|
</emphasis>
|
|
backwards
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
SPACE
|
|
</emphasis>
|
|
same as l
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
fx
|
|
</emphasis>
|
|
find x forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Fx
|
|
</emphasis>
|
|
find x backward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
;
|
|
</emphasis>
|
|
repeat last f F
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
,
|
|
</emphasis>
|
|
inverse of ;
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
|
|
|
</emphasis>
|
|
to specified column
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
%
|
|
</emphasis>
|
|
find matching { or }
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="words_sentence">
|
|
<title>
|
|
Words, sentences, paragraphs
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
w
|
|
</emphasis>
|
|
Word forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
b
|
|
</emphasis>
|
|
Word backward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
e
|
|
</emphasis>
|
|
End of word
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
)
|
|
</emphasis>
|
|
To next sentence
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
(
|
|
</emphasis>
|
|
Back sentence
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
}
|
|
</emphasis>
|
|
To next paragraph
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
{
|
|
</emphasis>
|
|
Back paragraph
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
W
|
|
</emphasis>
|
|
Blank delimited word
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
B
|
|
</emphasis>
|
|
Back W
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
E
|
|
</emphasis>
|
|
To end of W
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="marking_returning">
|
|
<title>
|
|
Marking and returning
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
``
|
|
</emphasis>
|
|
(press twice the back-quote ` key) Previous context
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
''
|
|
</emphasis>
|
|
(press twice the single-quote ` key) Previous context at first
|
|
non-white in line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
mx
|
|
</emphasis>
|
|
mark position with letter x
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
`x
|
|
</emphasis>
|
|
(back quote key and letter x) goto mark x
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
'x
|
|
</emphasis>
|
|
goto mark x at first non-white in line
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="corrections">
|
|
<title>
|
|
Corrections during insert
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-h
|
|
</emphasis>
|
|
Erase last character
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-w
|
|
</emphasis>
|
|
Erase last word
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
erase
|
|
</emphasis>
|
|
Press DELETE key, same as CTRL-h
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
kill
|
|
</emphasis>
|
|
Your kill key, erase input this line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
\
|
|
</emphasis>
|
|
Escapes CTRL-h, DELETE and kill
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ESC
|
|
</emphasis>
|
|
Ends insertion, back to command
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-?
|
|
</emphasis>
|
|
Interrupt, terminates insert
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-d
|
|
</emphasis>
|
|
Backtab over
|
|
<emphasis remap="it">
|
|
autoindent
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-v
|
|
</emphasis>
|
|
Quote non-printing character
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="ajusting">
|
|
<title>
|
|
Adjusting the screen
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-l
|
|
</emphasis>
|
|
Clear and redraw
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-r
|
|
</emphasis>
|
|
retype, eliminate @lines
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
z-CR
|
|
</emphasis>
|
|
redraw, current line at window top
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
z-
|
|
</emphasis>
|
|
redraw, current line at window bottom
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
z.
|
|
</emphasis>
|
|
redraw, current line at window center
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
/pat/z-
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
pat
|
|
</emphasis>
|
|
line bottom
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
tn
|
|
</emphasis>
|
|
Use n line window
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-e
|
|
</emphasis>
|
|
Scroll window down 1 line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-y
|
|
</emphasis>
|
|
Scroll window up 1 line
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="delete">
|
|
<title>
|
|
Delete
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
x
|
|
</emphasis>
|
|
Delete the character under the cursor
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
X
|
|
</emphasis>
|
|
Delete the charater before the cursor
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
D
|
|
</emphasis>
|
|
Delete to the end of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d^
|
|
</emphasis>
|
|
Delete back to start of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
dd
|
|
</emphasis>
|
|
Delete the current line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
ndd
|
|
</emphasis>
|
|
Delete
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
lines starting with the current one
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
dnw
|
|
</emphasis>
|
|
Delete
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
words starting from cursor
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="insert">
|
|
<title>
|
|
Insert, change
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
i
|
|
</emphasis>
|
|
Enter input mode inserting before the cursor
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
I
|
|
</emphasis>
|
|
Enter input mode inserting before the first non-blank character
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
a
|
|
</emphasis>
|
|
Enter input mode inserting after the cursor
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
A
|
|
</emphasis>
|
|
Enter input mode inserting after the end of the line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
o
|
|
</emphasis>
|
|
Open a new line below current line and enter input mode
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
O
|
|
</emphasis>
|
|
Open a new line above current line and enter input mode
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
r
|
|
</emphasis>
|
|
Replace the character under the cursor (does NOT enter input
|
|
mode)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
R
|
|
</emphasis>
|
|
Enter input mode replacing characters
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
C
|
|
</emphasis>
|
|
shift-c. Change rest of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
D
|
|
</emphasis>
|
|
shift-d. Delete rest of line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
s
|
|
</emphasis>
|
|
Substitute chars
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
S
|
|
</emphasis>
|
|
Substitute lines
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
J
|
|
</emphasis>
|
|
Join lines
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
J
|
|
</emphasis>
|
|
Join lines
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="copy">
|
|
<title>
|
|
Copy and Paste
|
|
</title>
|
|
<para>
|
|
The "yank buffer" is filled by
|
|
<emphasis remap="it">
|
|
EVERY
|
|
</emphasis>
|
|
delete command, or explicitely by
|
|
<emphasis remap="bf">
|
|
Y
|
|
</emphasis>
|
|
and
|
|
<emphasis remap="bf">
|
|
yy
|
|
</emphasis>
|
|
.
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
Y
|
|
</emphasis>
|
|
Copy the current line to the yank buffer
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
yy
|
|
</emphasis>
|
|
Copy
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
lines starting from the current to the yank buffer
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
p
|
|
</emphasis>
|
|
Paste the yank buffer after the cursor (or below the current
|
|
line)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
P
|
|
</emphasis>
|
|
Paste the yank buffer before the cursor (or above the current
|
|
line)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"
|
|
<emphasis remap="it">
|
|
x
|
|
</emphasis>
|
|
p
|
|
</emphasis>
|
|
Put from buffer x
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"
|
|
<emphasis remap="it">
|
|
x
|
|
</emphasis>
|
|
y
|
|
</emphasis>
|
|
Yank to buffer x
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
"
|
|
<emphasis remap="it">
|
|
x
|
|
</emphasis>
|
|
d
|
|
</emphasis>
|
|
Delete into buffer x
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="operators">
|
|
<title>
|
|
Operators (use double to affect lines)
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
d
|
|
</emphasis>
|
|
delete
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
c
|
|
</emphasis>
|
|
change
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
<
|
|
</emphasis>
|
|
left shift
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
>
|
|
</emphasis>
|
|
right shift
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
!
|
|
</emphasis>
|
|
filter through command
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
=
|
|
</emphasis>
|
|
indent for LISP
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
y
|
|
</emphasis>
|
|
yank text to buffer
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="search">
|
|
<title>
|
|
Search and replace
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
/
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
</emphasis>
|
|
Search forward for
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
?
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
</emphasis>
|
|
Search backward for
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
n
|
|
</emphasis>
|
|
Repeat the last search in the same direction
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
N
|
|
</emphasis>
|
|
Repeat the last search in the reverse direction
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
/
|
|
</emphasis>
|
|
Repeat the last search forward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
?
|
|
</emphasis>
|
|
Repeat the last search backward
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
[ addr ] s/from/to/ [ g ]
|
|
</emphasis>
|
|
Search for the occurence of
|
|
<emphasis remap="it">
|
|
from
|
|
</emphasis>
|
|
and replace it with
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
to
|
|
</emphasis>
|
|
</emphasis>
|
|
in the current line, or in the range
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
addr
|
|
</emphasis>
|
|
</emphasis>
|
|
(two line numbers seperated by command; 1,$ is the whole file).
|
|
Replaces one occurrence per line, or all occurrences if
|
|
<emphasis remap="bf">
|
|
<emphasis remap="it">
|
|
g
|
|
</emphasis>
|
|
</emphasis>
|
|
is specified. For example, :3,20s/someword/anotherword/g Will
|
|
replace "someword" with "anotherword" starting from line 3 to
|
|
line 20. 'g' is global means replace all occurrences of
|
|
"someword".
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="general">
|
|
<title>
|
|
General
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:sh
|
|
</emphasis>
|
|
Forks a shell (to be exited with CTRL-d)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:!
|
|
<emphasis remap="it">
|
|
command
|
|
</emphasis>
|
|
</emphasis>
|
|
Forks a shell to execute
|
|
<emphasis remap="it">
|
|
command
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set number
|
|
</emphasis>
|
|
Switch on line numbering
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:set nonumber
|
|
</emphasis>
|
|
Switch off line numbering
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="line_editor">
|
|
<title>
|
|
Line Editor Commands
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:
|
|
</emphasis>
|
|
Tells
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
that the next commands you issue will be line editor commands.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:sh
|
|
</emphasis>
|
|
Temporarily returns to the shell to perform some shell commands
|
|
without leaving
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-d
|
|
</emphasis>
|
|
Escapes the temporary return to the shell and returns to
|
|
<emphasis remap="bf">
|
|
vi
|
|
</emphasis>
|
|
so you can edit the current window.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
Goes to the
|
|
<emphasis remap="it">
|
|
n
|
|
</emphasis>
|
|
th line of the buffer.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
x,z
|
|
</emphasis>
|
|
<emphasis remap="bf">
|
|
w
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
filename
|
|
</emphasis>
|
|
Writes lines from the numbers
|
|
<emphasis remap="it">
|
|
x
|
|
</emphasis>
|
|
through the number
|
|
<emphasis remap="it">
|
|
z
|
|
</emphasis>
|
|
into a new file called
|
|
<emphasis remap="it">
|
|
filename
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:$
|
|
</emphasis>
|
|
Moves the cursor to the beginning of the last line in the
|
|
buffer.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:.,$d
|
|
</emphasis>
|
|
Deletes all the lines from the current line to the last line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:r
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
filename
|
|
</emphasis>
|
|
Inserts the contents of the file
|
|
<emphasis remap="it">
|
|
filename
|
|
</emphasis>
|
|
under the current line of the buffer.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:s
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
/text/new_text/
|
|
</emphasis>
|
|
Replaces the first instance of
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
on the current line with
|
|
<emphasis remap="it">
|
|
new_text
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:s
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
/text/new_text/g
|
|
</emphasis>
|
|
Replaces the every occurrence of
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
on the current line with
|
|
<emphasis remap="it">
|
|
new_text
|
|
</emphasis>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
:g
|
|
</emphasis>
|
|
<emphasis remap="it">
|
|
/text/s//new_text/g
|
|
</emphasis>
|
|
Changes every occurrence of
|
|
<emphasis remap="it">
|
|
text
|
|
</emphasis>
|
|
on the buffer to
|
|
<emphasis remap="it">
|
|
new_text
|
|
</emphasis>
|
|
.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="other_commands">
|
|
<title>
|
|
Other commands
|
|
</title>
|
|
<para>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
u
|
|
</emphasis>
|
|
Undo the last change
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
U
|
|
</emphasis>
|
|
Restore the current line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
~
|
|
</emphasis>
|
|
Change case
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
J
|
|
</emphasis>
|
|
Join the currentline with the next line
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
.
|
|
</emphasis>
|
|
Repeat last text changing command
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<emphasis remap="bf">
|
|
CTRL-g
|
|
</emphasis>
|
|
Show file name and line number
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="xml_editor">
|
|
<title>
|
|
Vim as XML Editor
|
|
</title>
|
|
<para>
|
|
If you do lot of XML editing with Vim, refer to this mini-howto on Vim
|
|
as XML Editor at
|
|
<ulink url="http://www.pinkjuice.com/howto/vimxml">
|
|
http://www.pinkjuice.com/howto/vimxml
|
|
</ulink>
|
|
. See also
|
|
<ulink url="http://www.protocol7.com/svg-wiki/?VimXml">
|
|
Vim XML Wiki page
|
|
</ulink>
|
|
,
|
|
<ulink url="http://vim.sourceforge.net/scripts/script.php?script_id=301">
|
|
Devin Weaver "Script Karma" - xmledit
|
|
</ulink>
|
|
a filetype plugin to help edit XML, HTML, and SGML documents,
|
|
<ulink url="http://www.vim.org/scripts/script_search_results.php?keywords=xml">
|
|
Vim.org XML scripts
|
|
</ulink>
|
|
,
|
|
<ulink url="http://www.vim.org/tips/tip_search_results.php?keywords=xml">
|
|
Vim.org XML tips
|
|
</ulink>
|
|
,
|
|
<ulink url="http://www.w3.org/TR/REC-xml.html#sec-well-formed">
|
|
w3.org - Well formed XML doc
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<sect2 id="matchit">
|
|
<title>
|
|
Matchit.vim & Xmledit.vim
|
|
</title>
|
|
<para>
|
|
With XML syntax recognition turned on, you can find the matching XML
|
|
tag by placing the cursor on the XML tag (but within the < and
|
|
>) and then pressing the % key. Note, however that you should not
|
|
place the cursor on the < or > since vim will simply match the
|
|
< or > . Visit
|
|
<ulink url="www.vim.org/scripts/script.php?script_id=39">
|
|
http://www.vim.org/scripts/script.php?script_id=39
|
|
</ulink>
|
|
For installation instructions enter:
|
|
<programlisting format="linespecific">
|
|
vim somefile.txt
|
|
:help add-local-help
|
|
rpm -qa | grep -i vim
|
|
rpm -ql vim-minimal | less
|
|
rpm -ql vim-common | less
|
|
ls /usr/share/vim/vim61/macros/matchit.*
|
|
mkdir -p ~/.vim/plugin
|
|
cp /usr/share/vim/vim61/macros/matchit.vim ~/.vim/plugin/
|
|
mkdir ~/.vim/doc
|
|
cp /usr/share/vim/vim61/macros/matchit.txt ~/.vim/doc/
|
|
vim some-xml-file.xml # And test out the % key to match the tags
|
|
</programlisting>
|
|
For xmledit.vim download the tar ball from
|
|
<ulink url="http://www.vim.org/scripts/script.php?script_id=301">
|
|
http://www.vim.org/scripts/script.php?script_id=301
|
|
</ulink>
|
|
and unpack this into ~/.vim for Unix and into $VIM/vimfiles folder for
|
|
MS DOS or MS Windows.
|
|
<programlisting format="linespecific">
|
|
cd ~/.vim
|
|
tar xvf xmledit.tar.gz
|
|
ln ftplugin/*.xml ~/.vim/plugin
|
|
vim some-xml-file.xml # And test out the autocreation of tags in insert mode
|
|
</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="vim_docbook">
|
|
<title>
|
|
Vim and Docbook - Useful key mappings
|
|
</title>
|
|
<para>
|
|
This is from
|
|
<ulink url="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/gvim/gvim.html#gVim-DocBook">
|
|
Ashley - gVim and Docbook
|
|
</ulink>
|
|
. One can write DocBook documents at an incredably faster rate if one
|
|
maps element entry to key bindings. A directory called xml was created
|
|
in the ftplugins directory of the gVim installation. Into this was
|
|
placed a vim file that contained macros to map key combinations to
|
|
element insertions. Comma preceeds each mapping, this is convenient
|
|
because if the user types comma followed by space, nothing happens,
|
|
but if the user types comma followed by one of the mapped key
|
|
combinations an element is inserted. Most of the mappings are
|
|
intuitive, for example, ulink is mapped onto ,-u-l. The mappings are
|
|
very easy to customise and the improvement in document creation speed
|
|
is amazing.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="XML_Validation">
|
|
<title>
|
|
XML Validation
|
|
</title>
|
|
<para>
|
|
To check for well-formedness of your XML document just do
|
|
<programlisting format="linespecific">
|
|
:!xmllint --valid --noout %
|
|
</programlisting>
|
|
And the --dtdvalid dtd allows validation of the document(s) against a
|
|
given DTD.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="wysiwyg">
|
|
<title>
|
|
Build Your "WYSIWYG" HTML Editor With Vi & Netscape
|
|
</title>
|
|
<para>
|
|
This section was written by
|
|
<ulink url="http://www.pcquest.com/content/linux/handson/101100102.asp">
|
|
Manas K Laha
|
|
</ulink>
|
|
, Aerospace Engineering Department, IIT Kharagpur, India. This is about
|
|
a quick and dirty way to create an HTML editor combining vi and
|
|
Netscape.
|
|
</para>
|
|
<para>
|
|
If vi (or one of its friends, such as elvis or vim ) is your favorite
|
|
text editor, as it is mine, you must surely long for a way of creating
|
|
HTML with it quickly and comfortably. And if with that you could get the
|
|
convenience of "WYSIWYG", wouldn't you just jump at it? All this is
|
|
indeed possible, and here we'll see how.
|
|
</para>
|
|
<para>
|
|
The major hurdles I've found in editing HTML with vi are
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
<para>
|
|
The need to write HTML tags. It appears that there are more tags
|
|
to be written than displayable matter. Moreover, some of these
|
|
tags have a syntax that is hard to remember.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
The need to keep track of whether an opening tag has been given
|
|
its proper closing tag at the right place (for example, whether a
|
|
< ol> has a matching < /ol> ).
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Difficulty in readily identifying matching pairs of tags.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</para>
|
|
<para>
|
|
These can be got around using some of the less used features of vi and
|
|
friends. In this article I shall use vim for definiteness, but the ideas
|
|
should apply to classic vi and its other look-alikes as well.
|
|
</para>
|
|
<para>
|
|
The "abbreviation" feature of vim:
|
|
</para>
|
|
<para>
|
|
Vim has a feature whereby it is possible to assign a keystroke sequence
|
|
to represent a string of characters in input mode. This is the ab colon
|
|
command. For example, the command
|
|
<programlisting format="linespecific">
|
|
:ab tT <tt> </tt></programlisting>
|
|
</para>
|
|
<para>
|
|
creates an abbreviation, named tT, for the sequence of characters <
|
|
tt>< /tt>. Then, in input mode, as soon as the characters tT
|
|
are typed, they are replaced by the string < tt>< /tt>.
|
|
Complicated HTML tags may also be abbreviated. The ab definition
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
:ab aH <a href=?http://?><!? { ?>^M
|
|
Comments here^M^D </a><!? } ?></programlisting>
|
|
</para>
|
|
<para>
|
|
makes aH the shorthand for
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
<a href=?http://?><!? { ?>
|
|
Comments here
|
|
</a><!? } ?>
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
where the two ^M s cause the two line breaks and the ^D causes the
|
|
closing < /a> tag to be indented back to be in line with the
|
|
opening < a> tag. (Indenting the matter enclosed within a matching
|
|
pair of tags makes reading and editing the raw HTML easier.) The syntax
|
|
of the tag is outlined, as an aid to memory. The 'Comments here' line is
|
|
a placeholder, to be replaced with appropriate text.
|
|
</para>
|
|
<para>
|
|
What are the { and } within HTML comments doing there? Aha! Those are
|
|
for matching the opening and closing tags (in this case < a> and
|
|
< /a>). The bracket matching feature of vi (using the % key) is
|
|
readily usable for the purpose. This can be really helpful when the
|
|
opening and closing tags are many lines apart and cannot be readily
|
|
matched 'by eye', such as can be the case with the < ol><
|
|
/ol> pair.
|
|
</para>
|
|
<para>
|
|
This technique can be extended to generate fancier HTML, for example
|
|
with frames. All one has to do is to define the appropriate
|
|
abbreviations. For example, the definition
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
:ab fS <frameset scrolling=?no?
|
|
frameborder=?0? framespacing=?0?
|
|
cols=?20%,80%?><!? { ?>^M </frameset> <!?
|
|
} ?></programlisting>
|
|
</para>
|
|
<para>
|
|
makes the string fS a convenient abbreviation for the pair of tags:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
<frameset scrolling=?no? frameborder=?0?
|
|
framespacing=?0? cols=?20%,80%?> <!? { ?>
|
|
</frameset><!? } ?></programlisting>
|
|
</para>
|
|
<para>
|
|
Some tags do not like comments to come in between the opening and
|
|
closing pair. The ones I have found are < title>< /title>
|
|
and < a\ href=?mailto:?> < /a>. Luckily, in both these the
|
|
opening and closing pair are never very far apart, so the
|
|
braces-within-comments feature is not needed.
|
|
</para>
|
|
<sect2 id="sample_vimhtml">
|
|
<title>
|
|
Sample .vimhtmlrc File
|
|
</title>
|
|
<para>
|
|
How do I tell vim about these abbreviations? I put all of them (and a
|
|
command to set some of vim's variables) in a file, which I call
|
|
.vimhtmlrc and which resides in my home directory, and invoke
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
vim -u ~/.vimhtmlrc index.html</programlisting>
|
|
</para>
|
|
<para>
|
|
where index.html is the HTML file I want to edit. This is what my
|
|
.vimhtmlrc file looks like:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
ab aH <a href=?http://?><!? { ?>^M
|
|
Comments here^M^D</a> <!? } ?>
|
|
|
|
ab aM <a href=?mailto:?>^M Comments
|
|
here^M^D </a>
|
|
|
|
ab bO <body bgcolor=#e0e0e0
|
|
text=#000000><!? { ?>^M </body> <!? } ?>
|
|
|
|
ab bR <br>
|
|
|
|
ab cE <center bgcolor=#e0e0e0
|
|
text=#000000><!? { ?>^M </center> <!? } ?>
|
|
|
|
ab cM <!? ^M ?>
|
|
|
|
ab cO <code> <!? { ?>^M </code> <!? } ?>
|
|
|
|
ab dL <dl><!? { ?>^M</dl><!? } ?>
|
|
|
|
ab dT <dt>
|
|
|
|
ab fO <font color=#000000>^M </font>
|
|
|
|
ab h1 <h1><!? { ?>^M Heading size
|
|
1^M^D </h1> <!? } ?>
|
|
|
|
ab h2 <h2><!? { ?>^M Heading size
|
|
2^M^D </h2><!? } ?>
|
|
|
|
ab h3 <h3><!? { ?>^M Heading size
|
|
3^M^D </h3> <!? } ?>
|
|
|
|
ab hD <head> <!? { ?>^M </head> <!? } ?>
|
|
|
|
ab hR <hr>
|
|
|
|
ab hT <html> <!? { ?>^M </html> <!? } ?>
|
|
|
|
ab iM <img src=??>
|
|
|
|
ab lI <li> <!? { ?>^M </li> <!? } ?>
|
|
|
|
ab oL <ol> <!? { ?>^M </ol> <!? } ?>
|
|
|
|
ab pR <pre> <!? { ?>^M </pre> <!? } ?>
|
|
|
|
ab tD <td> <!? { ?>^M </td> <!? } ?>
|
|
|
|
ab tL <title>^M Title here^M^D </title>
|
|
|
|
ab tS <table bgcolor=?#d0d0d0?> <!? {
|
|
?>^M </table> <!? } ?>
|
|
|
|
ab tT <tt> </tt>
|
|
|
|
ab uL <ul> <!? { ?>^M </ul> <!? } ?>
|
|
|
|
ab xB <b> </b>
|
|
|
|
ab xI <i> </i>
|
|
|
|
ab xP <p> <!? { ?>^M </p> <!? } ?>
|
|
se ai aw sw=4 ts=4 wm=10 showmode
|
|
showmatch ruler magic
|
|
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
When the ab commands are put in a file, to be read in by vim at
|
|
startup, then the leading :is not needed. The last line is a command
|
|
to set some of vim 's variables. Here is what they mean:
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
se set: tells vim to activate the options that follow autoindent: begin the next
|
|
ai line in the same column as this one (and not from column 1)
|
|
aw autowrite: automatically write file to disk when it changes on a TAB key, move cursor 4
|
|
ts=4 characters (and not the normal 8); this is my personal preference
|
|
sw=4 number of spaces to use for indentation chars from right margin where
|
|
wm=10 line wrapping starts (useful if one is writing running text and not programs)
|
|
message on status line to show
|
|
showmode current mode (for the novice, actually) briefly jump to matching
|
|
opening '(' or '{' or '[' as
|
|
showmatch soon as a closing ')' or '}' or ']' is typed; beep if no match
|
|
ruler show cursor line and column in status line some characters, such as '.'
|
|
magic and '*', have special meanings in search and replace patterns.</programlisting>
|
|
</para>
|
|
<para>
|
|
Typing help in a vim window shows the explanations for these options
|
|
and many more besides.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="wysiwyg_">
|
|
<title>
|
|
WYSIWYG
|
|
</title>
|
|
<para>
|
|
'WYSIWYG' has two parts to it. To begin with is the fact that Netscape
|
|
under Unix (and Linux) can be controlled remotely.
|
|
</para>
|
|
<para>
|
|
That is, you may control the behavior of an already running Netscape
|
|
through commands of the form
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
netscape -remote -noraise 'openFile(/home/mlaha/html/index.html)'</programlisting>
|
|
</para>
|
|
<para>
|
|
(If no Netscape is running, the command just exits with an error
|
|
message.) This command causes the Netscape browser window to attempt
|
|
to open the file /home/mlaha/html/index.html. For more on remote
|
|
controlling Netscape, see
|
|
<ulink url="http://home.netscape.com/newsref/std/x-remote.html">
|
|
"http://home.netscape.com/newsref/std/x-remote.html"
|
|
</ulink>
|
|
.
|
|
</para>
|
|
<para>
|
|
And then, there is atchange . Jeffrey Copeland and Jeffrey Haemer (
|
|
<ulink url="http://alumni.caltech.edu/~copeland/work/edit-web.html">
|
|
"http://alumni.caltech.edu/~copeland/work/edit-web.html"
|
|
</ulink>
|
|
,
|
|
<ulink url="ftp://ftp.ncifcrf.gov/pub/delila/atchange">
|
|
"ftp://ftp.ncifcrf.gov/pub/delila/atchange"
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.lecb.ncifcrf.gov/~toms/atchange.html">
|
|
"http://www.lecb.ncifcrf.gov/~toms/atchange.html"
|
|
</ulink>
|
|
) describe a little shell script, called atchange, that waits in the
|
|
background for a named file to change and then invokes a specified
|
|
command. Thus,
|
|
</para>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
atchange index.html 'netscape -noraise -remote 'openFile(/home/mlaha/html/index.html)'' &</programlisting>
|
|
</para>
|
|
<para>
|
|
would cause atchange to run in the background, watching the file
|
|
index.html and, as soon as it changed, ask Netscape to display it
|
|
afresh. If you were editing index.html with vi, then, when you saved
|
|
it (with :w, say), atchange would spring into action and Netscape
|
|
would update its display.
|
|
</para>
|
|
<para>
|
|
If you wish to edit another HTML file, you have to quit vim, kill the
|
|
current invocation of atchange, then start it again with the name of
|
|
the new file in place of index.html and begin editing that file with
|
|
vim.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="wysi_uses">
|
|
<title>
|
|
Other 'WYSIWYG' uses
|
|
</title>
|
|
<para>
|
|
As you may have guessed, atchange can be used in other instances, too.
|
|
You can make a handy 'WYSIWYG' LaTeX editor by having atchange monitor
|
|
your LaTeX source and, when it changed, run the necessary programs to
|
|
convert it to Postscript. The 'WYSIWYG' capability is provided in this
|
|
case by invoking Ghostview with the monitoring option (-watch) that
|
|
causes it to redisplay its current Postscript file whenever that file
|
|
changes. Thus, every time you saved your LaTeX source file in the
|
|
editor, the Postscript output with the latest changes would be
|
|
automatically displayed in the Ghostscript window.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="atchange">
|
|
<title>
|
|
Source code for atchange
|
|
</title>
|
|
<para>
|
|
<programlisting format="linespecific">
|
|
#!/usr/local/bin/perl
|
|
# by Jeff Haemer
|
|
# and a tip o' the hat to Tom Schneider
|
|
# who wrote the original version as a shell script
|
|
# version = 2.07 of atchange 1999 Dec 30
|
|
# 1999 Dec 18: Added shell call to /bin/csh so that
|
|
# atchange works under Linux.
|
|
# 1999 Feb 5: By setting the PERLCSH variable, the new shell can tell
|
|
# it has been called by atchange.
|
|
# The test inside the .cshrc is:
|
|
#if ( (! $?PERLCSH ) && $?prompt) then
|
|
# stty erase '^H'
|
|
# set prompt = "`uname -n` \!% "
|
|
#endif
|
|
# This is necessary under Sun Solaris 2.6 because otherwise the
|
|
# call to stty gives an error message now.
|
|
# previous change: 1997 Jan 9
|
|
# delay time is 0.25 seconds
|
|
# For current version and other information about this program, see:
|
|
# http://www.lecb.ncifcrf.gov/~toms/atchange.html
|
|
# Tom Schneider
|
|
# National Cancer Institute
|
|
# Laboratory of Mathematical Biology
|
|
# Frederick, Maryland 21702-1201
|
|
# toms@ncifcrf.gov
|
|
# http://www.lecb.ncifcrf.gov/~toms/
|
|
# 1999 Dec 30: James Haefner (jhaefner@biology.usu.edu)
|
|
# has found that some changes are needed to make atchange
|
|
# work under Linux. See the web site for details.
|
|
# This code will be revised when a good solution is found.
|
|
$0 =~ s(.*/)(); # basename
|
|
$usage = "usage: $0 filename cmd | $0 command_file";
|
|
@ARGV || die $usage; # check for proper invocation
|
|
# This allows the .cshrc to know that atchange has called it:
|
|
$ENV{'PERLCSH'} = "TRUE";
|
|
# Haefner Suggestion 1999 Dec 18:
|
|
##if default SHELL is sh or csh or tcsh use the following line
|
|
###$shell = $ENV{"SHELL"} ? $ENV{"SHELL"} : "/bin/sh";
|
|
##if default SHELL is bash (eg, Linux) use the following line
|
|
# 1999 Dec 28 - this is not a good idea - untestable by me
|
|
# $shell = "/bin/csh";
|
|
$shell = $ENV{"SHELL"} ? $ENV{"SHELL"} : "/bin/sh";
|
|
open(SHELL, "|$shell") || die "Can't pipe to $shell: $!";
|
|
select(SHELL); $| = 1;
|
|
if (@ARGV > 1) { # it's a file and a command
|
|
$file = shift; # peel off the filename
|
|
$cmd{$file} = join(" ", @ARGV) . "\n"; # and the command
|
|
$old{$file} = (stat($file))[9]; # mod time.
|
|
} else { # it's a program
|
|
open(PGM, shift) || die "Can't open $_: $!";
|
|
$/ = ""; # paragraph mode
|
|
while(<PGM>) { # first read the program
|
|
s/#.*\n/\n/g;
|
|
($file, $cmd) = /(\S*)\s+([^\000]+)/;
|
|
$cmd{$file} = $cmd;
|
|
unless ($file) { print $cmd{$file}; next; }
|
|
if ($file && ! $cmd{$file}) { warn "odd line"; next; };
|
|
$old{$file} = (stat($file))[9]; # mod time.
|
|
}
|
|
}
|
|
while(1) {
|
|
# sleep 1; # wait a second, then
|
|
select(undef, undef, undef, 0.25); # wait a quarter second, then
|
|
foreach (keys %cmd) { # rip through the whole list
|
|
atchange($_);
|
|
}
|
|
}
|
|
close(SHELL);
|
|
sub atchange { # if $file has changed, do $cmd{$file}
|
|
my($file) = @_;
|
|
my($new);
|
|
$new = (stat($file))[9];
|
|
return 0 if ($old{$file} == $new);
|
|
while (1) { # wait until it stops changing
|
|
$old{$file} = $new;
|
|
sleep 1;
|
|
$new = (stat($file))[9];
|
|
if ($old{$file} == $new) {
|
|
print $cmd{$file};
|
|
return 1;
|
|
}
|
|
}
|
|
}</programlisting>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="html_beautifier">
|
|
<title>
|
|
HTML Beautifier Inside Vim : Program Tidy
|
|
</title>
|
|
<para>
|
|
While editing HTML files with Vim, it is possible to automatically
|
|
check syntax errors and beautify the code with program like Tidy
|
|
</para>
|
|
<para>
|
|
(Visit
|
|
<ulink url="http://www.w3.org/People/Raggett/tidy">
|
|
Raggett Tidy
|
|
</ulink>
|
|
,
|
|
<ulink url="http://tidy.sourceforge.net">
|
|
Tidy Project
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.tldp.org/HOWTO/C-C++Beautifier-HOWTO">
|
|
Beatifier HOWTO
|
|
</ulink>
|
|
).
|
|
</para>
|
|
<para>
|
|
Inside Vim (gvim), click on menu Tools->'Set Compiler'->'Tidy'
|
|
and give command ":make". The :make command will run the tidy and show
|
|
all errors if any. You can also edit the setting file tidy.vim and
|
|
customize:
|
|
<programlisting format="linespecific">
|
|
ls /usr/share/vim/vim61/compiler
|
|
cd /usr/share/vim/vim61/compiler
|
|
cp tidy.vim tidy.vim.backup
|
|
man tidy # And the manual page of tidy and see options..
|
|
tidy -h | less # See help about using tidy
|
|
vi tidy.vim
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
See also related HTML validators section (HTML Beautifier section) in
|
|
<ulink url="http://www.tldp.org/HOWTO/C-C++Beautifier-HOWTO">
|
|
Beatifier HOWTO
|
|
</ulink>
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="emacs_old_habits">
|
|
<title>
|
|
Emacs - Old Habits Die Hard !
|
|
</title>
|
|
<para>
|
|
If you were using Emacs before and now started using Vim & vi, then
|
|
this mistake is commited very often and will be quite annoying to you.
|
|
</para>
|
|
<para>
|
|
You hit "control x" "control s" to save the file and Vim stops dead. How
|
|
to rescue without killing the xwindow containing the vim process, and
|
|
recovering. You will see that there is no response at the keyboard.
|
|
</para>
|
|
<para>
|
|
The explanation for this behaviour is : It is not the feature of vim but
|
|
it is the feature of the xterm 'terminal'. The "control s" means stop
|
|
feeding to terminal output, so you do not see any output. To get out of
|
|
it do "control q" (to quit out of stop output). This happens only in
|
|
vim/vi and not in gvim (graphical Vim).
|
|
</para>
|
|
<para>
|
|
Also in xterm, at the bash prompt type something and do "control s" and
|
|
type something you will not see output. Now type "control q" you will
|
|
see output.
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="related_urls">
|
|
<title>
|
|
Related URLs
|
|
</title>
|
|
<para>
|
|
Related VIM URLs are at -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
C and C++ Beautifer
|
|
<ulink url="http://www.metalab.unc.edu/LDP/HOWTO/C-C++Beautifier-HOWTO.html">
|
|
"http://www.metalab.unc.edu/LDP/HOWTO/C-C++Beautifier-HOWTO.html"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Linux goodies main site is at
|
|
<ulink url="http://milkyway.has.it">
|
|
"http://milkyway.has.it"
|
|
</ulink>
|
|
and mirror at
|
|
<ulink url="http://www.milkywaygalaxy.freeservers.com">
|
|
"http://www.milkywaygalaxy.freeservers.com"
|
|
</ulink>
|
|
Mirror sites are at -
|
|
<ulink url="http://www.angelfire.com/country/aldev0">
|
|
angelfire
|
|
</ulink>
|
|
,
|
|
<ulink url="http://www.geocities.com/alavoor/index.html">
|
|
geocities
|
|
</ulink>
|
|
,
|
|
<ulink url="http://aldev0.virtualave.net">
|
|
virtualave
|
|
</ulink>
|
|
,
|
|
<ulink url="http://members.fortunecity.com/aldev">
|
|
Fortunecity
|
|
</ulink>
|
|
,
|
|
<ulink url="http://aldev.freewebsites.com">
|
|
Freewebsites
|
|
</ulink>
|
|
,
|
|
<ulink url="http://members.tripod.lycos.com/aldev">
|
|
Tripod
|
|
</ulink>
|
|
,
|
|
<ulink url="http://www.101xs.com/101xs/aldev">
|
|
101xs
|
|
</ulink>
|
|
,
|
|
<ulink url="http://aldev0.50megs.com">
|
|
50megs
|
|
</ulink>
|
|
,
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="other_formats">
|
|
<title>
|
|
Other Formats of this Document
|
|
</title>
|
|
<para>
|
|
This document is published in 14 different formats namely - DVI,
|
|
Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text
|
|
Format), Plain-text, Unix man pages, single HTML file, SGML (Linuxdoc
|
|
format), SGML (Docbook format), MS WinHelp format.
|
|
</para>
|
|
<para>
|
|
This howto document is located at -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.linuxdoc.org">
|
|
"http://www.linuxdoc.org"
|
|
</ulink>
|
|
and click on HOWTOs and search for howto document name using
|
|
CTRL+f or ALT+f within the web-browser.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
You can also find this document at the following mirrors sites -
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.caldera.com/LDP/HOWTO">
|
|
"http://www.caldera.com/LDP/HOWTO"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.linux.ucla.edu/LDP">
|
|
"http://www.linux.ucla.edu/LDP"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.cc.gatech.edu/linux/LDP">
|
|
"http://www.cc.gatech.edu/linux/LDP"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<ulink url="http://www.redhat.com/mirrors/LDP">
|
|
"http://www.redhat.com/mirrors/LDP"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Other mirror sites near you (network-address-wise) can be found at
|
|
<ulink url="http://www.linuxdoc.org/mirrors.html">
|
|
"http://www.linuxdoc.org/mirrors.html"
|
|
</ulink>
|
|
select a site and go to directory /LDP/HOWTO/xxxxx-HOWTO.html
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
You can get this HOWTO document as a single file tar ball in HTML,
|
|
DVI, Postscript or SGML formats from -
|
|
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other-formats/">
|
|
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other-formats/"
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.linuxdoc.org/docs.html#howto">
|
|
"http://www.linuxdoc.org/docs.html#howto"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Plain text format is in:
|
|
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO">
|
|
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.linuxdoc.org/docs.html#howto">
|
|
"http://www.linuxdoc.org/docs.html#howto"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Single HTML file format is in:
|
|
<ulink url="http://www.linuxdoc.org/docs.html#howto">
|
|
"http://www.linuxdoc.org/docs.html#howto"
|
|
</ulink>
|
|
</para>
|
|
<para>
|
|
Single HTML file can be created with command (see man sgml2html) -
|
|
sgml2html -split 0 xxxxhowto.sgml
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Translations to other languages like French, German, Spanish,
|
|
Chinese, Japanese are in
|
|
<ulink url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO">
|
|
"ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"
|
|
</ulink>
|
|
and
|
|
<ulink url="http://www.linuxdoc.org/docs.html#howto">
|
|
"http://www.linuxdoc.org/docs.html#howto"
|
|
</ulink>
|
|
Any help from you to translate to other languages is welcome.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
The document is written using a tool called "SGML-Tools" which can be
|
|
got from -
|
|
<ulink url="http://www.sgmltools.org">
|
|
"http://www.sgmltools.org"
|
|
</ulink>
|
|
Compiling the source you will get the following commands like
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
sgml2html xxxxhowto.sgml (to generate html file)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
sgml2html -split 0 xxxxhowto.sgml (to generate a single page html
|
|
file)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
sgml2rtf xxxxhowto.sgml (to generate RTF file)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
sgml2latex xxxxhowto.sgml (to generate latex file)
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<sect2 id="acrobatpdf">
|
|
<title>
|
|
Acrobat PDF format
|
|
</title>
|
|
<para>
|
|
PDF file can be generated from postscript file using either acrobat
|
|
<emphasis remap="bf">
|
|
distill
|
|
</emphasis>
|
|
or
|
|
<emphasis remap="bf">
|
|
Ghostscript
|
|
</emphasis>
|
|
. And postscript file is generated from DVI which in turn is generated
|
|
from LaTex file. You can download distill software from
|
|
<ulink url="http://www.adobe.com">
|
|
"http://www.adobe.com"
|
|
</ulink>
|
|
. Given below is a sample session:
|
|
<programlisting format="linespecific">
|
|
bash$ man sgml2latex
|
|
bash$ sgml2latex filename.sgml
|
|
bash$ man dvips
|
|
bash$ dvips -o filename.ps filename.dvi
|
|
bash$ distill filename.ps
|
|
bash$ man ghostscript
|
|
bash$ man ps2pdf
|
|
bash$ ps2pdf input.ps output.pdf
|
|
bash$ acroread output.pdf &</programlisting>
|
|
Or you can use Ghostscript command
|
|
<emphasis remap="bf">
|
|
ps2pdf
|
|
</emphasis>
|
|
. ps2pdf is a work-alike for nearly all the functionality of Adobe's
|
|
Acrobat Distiller product: it converts PostScript files to Portable
|
|
Document Format (PDF) files.
|
|
<emphasis remap="bf">
|
|
ps2pdf
|
|
</emphasis>
|
|
is implemented as a very small command script (batch file) that
|
|
invokes Ghostscript, selecting a special "output device" called
|
|
<emphasis remap="bf">
|
|
pdfwrite
|
|
</emphasis>
|
|
. In order to use ps2pdf, the pdfwrite device must be included in the
|
|
makefile when Ghostscript was compiled; see the documentation on
|
|
building Ghostscript for details.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="linuxdoc2docbook">
|
|
<title>
|
|
Convert Linuxdoc to Docbook format
|
|
</title>
|
|
<para>
|
|
This document is written in linuxdoc SGML format. The Docbook SGML
|
|
format supercedes the linuxdoc format and has lot more features than
|
|
linuxdoc. The linuxdoc is very simple and is easy to use. To convert
|
|
linuxdoc SGML file to Docbook SGML use the program
|
|
<emphasis remap="bf">
|
|
ld2db.sh
|
|
</emphasis>
|
|
and some perl scripts. The ld2db output is not 100% clean and you need
|
|
to use the
|
|
<emphasis remap="bf">
|
|
clean_ld2db.pl
|
|
</emphasis>
|
|
perl script. You may need to manually correct few lines in the
|
|
document.
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Download ld2db program from
|
|
<ulink url="http://www.dcs.gla.ac.uk/~rrt/docbook.html">
|
|
"http://www.dcs.gla.ac.uk/~rrt/docbook.html"
|
|
</ulink>
|
|
or from
|
|
<ulink url="http://milkyway.has.it">
|
|
"http://milkyway.has.it"
|
|
</ulink>
|
|
and mirror at
|
|
<ulink url="http://www.milkywaygalaxy.freeservers.com">
|
|
Al Dev site
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Download the cleanup_ld2db.pl perl script from
|
|
<ulink url="http://milkyway.has.it">
|
|
"http://milkyway.has.it"
|
|
</ulink>
|
|
and mirror at
|
|
<ulink url="http://www.milkywaygalaxy.freeservers.com">
|
|
Al Dev site
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
The ld2db.sh is not 100% clean, you will get lots of errors when you
|
|
run
|
|
<programlisting format="linespecific">
|
|
bash$ ld2db.sh file-linuxdoc.sgml db.sgml
|
|
bash$ cleanup.pl db.sgml > db_clean.sgml
|
|
bash$ gvim db_clean.sgml
|
|
bash$ docbook2html db.sgml</programlisting>
|
|
And you may have to manually edit some of the minor errors after
|
|
running the perl script. For e.g. you may need to put closing tag <
|
|
/Para> for each < Listitem>
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="mswinhelp">
|
|
<title>
|
|
Convert to MS WinHelp format
|
|
</title>
|
|
<para>
|
|
You can convert the SGML howto document to Microsoft Windows Help
|
|
file, first convert the sgml to html using:
|
|
<programlisting format="linespecific">
|
|
bash$ sgml2html xxxxhowto.sgml (to generate html file)
|
|
bash$ sgml2html -split 0 xxxxhowto.sgml (to generate a single page html file)</programlisting>
|
|
Then use the tool
|
|
<ulink url="http://javadocs.planetmirror.com/htmltohlpe.html">
|
|
HtmlToHlp
|
|
</ulink>
|
|
. You can also use sgml2rtf and then use the RTF files for generating
|
|
winhelp files.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="readformats">
|
|
<title>
|
|
Reading various formats
|
|
</title>
|
|
<para>
|
|
In order to view the document in dvi format, use the xdvi program. The
|
|
xdvi program is located in tetex-xdvi*.rpm package in Redhat Linux
|
|
which can be located through ControlPanel | Applications | Publishing
|
|
| TeX menu buttons. To read dvi document give the command -
|
|
<screen format="linespecific">
|
|
xdvi -geometry 80x90 howto.dvi man xdvi
|
|
</screen>
|
|
And resize the window with mouse. To navigate use Arrow keys, Page Up,
|
|
Page Down keys, also you can use 'f', 'd', 'u', 'c', 'l', 'r', 'p',
|
|
'n' letter keys to move up, down, center, next page, previous page
|
|
etc. To turn off expert menu press 'x'.
|
|
</para>
|
|
<para>
|
|
You can read postscript file using the program 'gv' (ghostview) or
|
|
'ghostscript'. The ghostscript program is in ghostscript*.rpm package
|
|
and gv program is in gv*.rpm package in Redhat Linux which can be
|
|
located through ControlPanel | Applications | Graphics menu buttons.
|
|
The gv program is much more user friendly than ghostscript. Also
|
|
ghostscript and gv are available on other platforms like OS/2, Windows
|
|
95 and NT, you view this document even on those platforms.
|
|
</para>
|
|
<para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Get ghostscript for Windows 95, OS/2, and for all OSes from
|
|
<ulink url="http://www.cs.wisc.edu/~ghost">
|
|
"http://www.cs.wisc.edu/~ghost"
|
|
</ulink>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
To read postscript document give the command -
|
|
<screen format="linespecific">
|
|
gv howto.ps ghostscript howto.ps
|
|
</screen>
|
|
</para>
|
|
<para>
|
|
You can read HTML format document using Netscape Navigator, Microsoft
|
|
Internet explorer, Redhat Baron Web browser or any of the 10 other web
|
|
browsers.
|
|
</para>
|
|
<para>
|
|
You can read the latex, LyX output using LyX a X-Windows front end to
|
|
latex.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="copyright">
|
|
<title>
|
|
Copyright Notice
|
|
</title>
|
|
<para>
|
|
Copyright policy is GNU/GPL as per LDP (Linux Documentation project).
|
|
LDP is a GNU/GPL project. Additional restrictions are - you must retain
|
|
the author's name, email address and this copyright notice on all the
|
|
copies. If you make any changes or additions to this document then you
|
|
should notify all the authors of this document.
|
|
</para>
|
|
</sect1>
|
|
</article>
|