*vimtips.txt* This file comes from the Vim Online tip database.  These tips
were downloaded on Tue, 24 Sep 2002 15:27:26 -0700 More tips can be found at <A
HREF="http://vim.sf.net/tip_index.php">http://vim.sf.net/tip_index.php</A><BR>
A new tip file can be downloaded from <A
HREF="http://vim.sf.net/tip_download.php">http://vim.sf.net/tip_download.php</A><BR>

Thanks for using vim online.

<Tip category="KVim"> <html><center>the super star</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=1">http://vim.sf.net/tip_view.php?tip_id=1</A><BR>

When a discussion started about learning vim on the vim list Juergen Salk
mentioned the "*" key as something that he wished he had know earlier. When
I read the mail I had to go help on what the heck the "*" did. I also wish
I had known earlier...

Using the "*" key while in normal mode searches for the word under the cursor.

If that doesn't save you a lot of typing, I don't know what will.

</pre></tip> </html> <Tip category="KVim"> <html><center>easy
edit of files in the same directory</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=2">http://vim.sf.net/tip_view.php?tip_id=2</A><BR>

It was often frustrating when I would open a file deep in the code tree and
then realize I wanted to open another file in that same directory. Douglas
Potts taught me a nice way to do this. Add the following snipit to your vimrc:

"   Edit another file in the same directory as the current file "   uses
expression to extract path from current file's path "  (thanks Douglas Potts)
if has("unix")
    map ,e :e &lt;C-R&gt;=expand("%:p:h") . "/" &lt;CR&gt;
else
    map ,e :e &lt;C-R&gt;=expand("%:p:h") . "\" &lt;CR&gt;
endif

Then when you type ,e in normal mode you can use tab to complete to the
file. You can also expand this to allow for spitting, etc. Very very nice.

</pre></tip> </html> <Tip category="KVim"> <html><center>use
vim to quickly compile java files</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=3">http://vim.sf.net/tip_view.php?tip_id=3</A><BR>

For a number of years I used vim on an SGI box. When I left my job at SGI
I went to a company that developed on PCs. For 2 years I used IDEs. I was
unhappy. I was frustrated. I couldn't figure out why. (Beyond my machine
crashing twice a day.) Finally I upgraded to windows 2000 (kind of stable!) and
started using vim as an IDE. All was good. Here is how you use vim to compile
your java:

1. While I'm sure this works with javac, javac is slow slow slow. So download
the Jikes complier first. (Jikes is from ibm, search on google for jikes
and you will find it..available on most platforms.)

2. Add the following to your vimrc:

set makeprg=jikes -nowarn -Xstdout +E % set
errorformat=%f:%l:%c:%*\d:%*\d:%*\s%m

3. When you are editing a java file type :make and it will compile the
current file and jump you to the first error in the file (if any). Read
":help quickfix" for how to move between errors.

To setup your classpath environment either launch gvim from a shell that
has your classpath/path setup or use the "let" command to configure it in
your vimrc.

</pre></tip> </html> <Tip category="KVim">
<html><center>Any word completion</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=4">http://vim.sf.net/tip_view.php?tip_id=4</A><BR>

Either when programming or writing, I tend to have some identifiers or words
that I use all the time. By sheer accident, I noticed the 'ctrl-n' command,
that will attempt to complete the word under the cursor. Hit it once, and it
will try to complete it with the first match in the current file. If there is
no match, it will (at least in the case of C code) search through all files
included from the current one. Repeated invocations will cycle through all
found matches.

</pre></tip> </html> <Tip category="KVim">
<html><center>Quickly searching for a word</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=5">http://vim.sf.net/tip_view.php?tip_id=5</A><BR>

To search for a word under the cursor in the current file you can use either
the "*" or "#" keys.

The "*" key will search for the word from the current cursor position to
the end of the file. The "#" key will search for the word from the current
cursor position to the top of the file.

Note that the above two keys will search for the whole word and not the
partial word.  This is equivalent to using the &lt;word&gt; pattern in the
search commands (/ and ?).

To search for partial matches, you can use the "g*" and "g#" key sequence.

You can also use the mouse to search for a word.  This will only work in
the GUI version of VIM (gvim) or a console version of VIM in an xterm which
accepts a mouse. Also, the 'mousemodel' should be set to 'extend'.  Add the
following line to your .vimrc:

set mousemodel=extend

To search for a word under the cursor from the current cursor position to
the end of the file, press the shift key and click on the word using the
left mouse button.  To search in the opposite direction, press the shift
key and click on the word using the the right mouse button.

To get more help on these, use

:help * :help # :help g* :help g# :help &lt;S-LeftMouse&gt; :help
&lt;S-RightMouse&gt;

</pre></tip> </html> <Tip category="KVim">
<html><center>Using the % key</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=6">http://vim.sf.net/tip_view.php?tip_id=6</A><BR>

The % key can be used

1. To jump to a matching opening or closing parenthesis, square
   bracket or a curly brace i.e. ([{}])
2. To jump to start or end of a C-style comment /* */.  3. To jump to a
matching #if, #ifdef, #else, #elif, #endif C
   preprocessor conditionals.

To get more information about this, do

             :help %

The % key can be extended to support other matching pairs by modifying the
"matchpairs" option.  Read the help on

             :help matchpairs

</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
to the start and end of a code block</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=7">http://vim.sf.net/tip_view.php?tip_id=7</A><BR>

To jump to the beginning of a C code block (while, switch, if etc), use the
[{ command.

To jump to the end of a C code block (while, switch, if etc), use the ]}
command.

The above two commands will work from anywhere inside the code block.

To jump to the beginning of a parenthesis use the [( command.

To jump to the end of a parenthesis use the ]) command.

To get more help on these commands, do

:help [{ :help ]} :help [( :help ])

</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
to the declaration of a local/global variable</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=8">http://vim.sf.net/tip_view.php?tip_id=8</A><BR>

'gd' command: To jump to the declaration of a local variable in a C program,
position the cursor on the name of the variable and use the gd command.

'gD' command: To jump to the declaration of a global variable in a C program,
position the cursor on the name of the variable and use the gD command.

</pre></tip> </html> <Tip category="KVim"> <html><center>Displaying
a variable/macro definition</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=9">http://vim.sf.net/tip_view.php?tip_id=9</A><BR>

To display the definition of a variable, place the cursor on the variable
and use the [i command.  To display a macro definition, place the cursor on
the macro name and use the [d command.  Note that these commands will work
most of the time (not all the time).  To get more help on these commands, use

:help [i :help [d

</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping
to previosuly visited locations in a file</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=10">http://vim.sf.net/tip_view.php?tip_id=10</A><BR>

Vim remembers all the locations visited by you in a file in a session.
You can jump to the older locations by pressing the Ctrl-O key.  You can
jump to the newer locations by pressing the Ctrl-I or the &lt;Tab&gt; key.

To get more help on these keys, use

:help CTRL-O :help CTRL-I :help jump-motions

</pre></tip> </html> <Tip category="KVim"> <html><center>Completing
words quicky in insert mode</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=11">http://vim.sf.net/tip_view.php?tip_id=11</A><BR>

In Insert mode, press the Ctrl-p or Ctrl-n key to complete part of a word
that has been typed.

This is useful while typing C programs to complete long variable and
function names.  This also helps in avoiding typing mistakes.

Note that using the 'complete' option, you can complete keywords defined in
one of the include files, tag file, etc.

To get more help on this, use

:help i_Ctrl-N :help i_Ctrl-P :help ins-completion :help complete

</pre></tip> </html> <Tip category="KVim">
<html><center>Converting tabs to spaces</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=12">http://vim.sf.net/tip_view.php?tip_id=12</A><BR>

To insert space characters whenever the tab key is pressed, set the
'expandtab' option:

        set expandtab

With this option set, if you want to enter a real tab character use
Ctrl-V&lt;Tab&gt; key sequence.

To control the number of space characters that will be inserted when the tab
key is pressed, set the 'tabstop' option.  For example, to insert 4 spaces
for a tab, use:

        set tabstop=4

After the 'expandtab' option is set, all the new tab characters entered will
be changed to spaces.  This will not affect the existing tab characters.
To change all the existing tab characters to match the current tab settings,
use

        :retab

To change the number of space characters inserted for indentation, use the
'shiftwidth' option:

        set shiftwidth=4

For example, to get the following coding style,
        - No tabs in the source file - All tab characters are 4 space
        characters

use the following set of options:

        set tabstop=4 set shiftwidth=4 set expandtab

Add the above settings to your .vimrc file.

To get more help on these options, use :help tabstop :help shiftwidth :help
expandtab

</pre></tip> </html> <Tip category="KVim">
<html><center>Incremental search</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=13">http://vim.sf.net/tip_view.php?tip_id=13</A><BR>

To move the cursor to the matched string, while typing the search string,
set the following option in the .vimrc file:

        set incsearch

You can complete the search by pressing the Enter key.  To cancel the search,
press the escape key.

</pre></tip> </html> <Tip category="KVim"> <html><center>Highlighting
all the search pattern matches</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=14">http://vim.sf.net/tip_view.php?tip_id=14</A><BR>

To highlight all the search pattern matches in a file set the following option:

        :set hlsearch

After this option is set, if you search for a pattern, all the matches in
the file will be highlighted in yellow.

To disable the highlighting temporarily, use the command

        :nohlsearch

This command will remove the highlighting for the current search.
The highlighting will come back for the next search.

To disable the highlighting completely, set the following option:

        :set nohlsearch

By default, the hlsearch option is turned off.

To get more help on this option, use

:help 'hlsearch' :help :nohlsearch

</pre></tip> </html> <Tip category="KVim">
<html><center>Displaying status line always</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=15">http://vim.sf.net/tip_view.php?tip_id=15</A><BR>

To display the status line always, set the following option in your .vimrc
file:

        set laststatus=2

The advantage of having the status line displayed always is, you can see
the current mode, file name, file status, ruler, etc.

To get more help on this, use

:help laststatus

</pre></tip> </html> <Tip category="KVim"> <html><center>Avoiding
the "Hit ENTER to continue" prompts</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=16">http://vim.sf.net/tip_view.php?tip_id=16</A><BR>

To avoid the "Hit ENTER to continue" prompt, use the 'shortmess' option.
Add the following line to your .vimrc file:

    set shortmess=a

Also, you can increase the height of the command line to 2

    set cmdheight=2

The default command height is 1.

To get more help on these options, use

:help hit-enter :help shortmess :help cmdheight

</pre></tip> </html> <Tip category="KVim"> <html><center>Erasing
previosuly entered characters in insert mode</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=17">http://vim.sf.net/tip_view.php?tip_id=17</A><BR>

In insert mode, to erase previously entered characters, set the following
option:

        set backspace=2

By default, this option is empty.  If this option is empty, in insert mode,
you can not erase characters entered before this insert mode started.
This is the standard Vi behavior.

To get more help on this, use

:help 'backspace'

</pre></tip> </html> <Tip category="KVim">
<html><center>Cleanup your HTML</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=18">http://vim.sf.net/tip_view.php?tip_id=18</A><BR>

From Johannes Zellner on the vim list:

You can use vim's makeprg and equalprg to clean up HTML. First download
html tidy from <A HREF="http://www.w3.org/People/Raggett/tidy/. Then use
the following commands.">http://www.w3.org/People/Raggett/tidy/. Then use
the following commands.</A><BR>

vim6?  exe 'setlocal equalprg=tidy -quiet -f '.&errorfile setlocal makeprg=tidy
-quiet -e %

vim5?  exe 'set equalprg=tidy -quiet -f '.&errorfile set makeprg=tidy -quiet
-e %

At this point you can use make to clean up the full file or you can use =
to clean up sections.

:help = :help equalprg :help makeprg

</pre></tip> </html> <Tip category="KVim">
<html><center>line numbers...</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=19">http://vim.sf.net/tip_view.php?tip_id=19</A><BR>

I have started doing all my code reviews on a laptop because of the number
command.

:set number will put line numbers along the left side of a window

:help number

</pre></tip> </html> <Tip category="KVim"> <html><center>Are *.swp
and *~ files littering your working directory?</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=20">http://vim.sf.net/tip_view.php?tip_id=20</A><BR>

Have you ever been frustrated at swap files and backups cluttering up your
working directory?

Untidy:
  ons.txt ons.txt~ README README~ tester.py tester.py~

Here are a couple of options that can help:

  set   backupdir=./.backup,.,/tmp set   directory=.,./.backup,/tmp

This way, if you want your backups to be neatly grouped, just create
a directory called '.backup' in your working directory.  Vim will stash
backups there. The 'directory' option controls where swap files go. If your
working directory is not writable, Vim will put the swap file in one of the
specified places.

</pre></tip> </html> <Tip category="KVim">
<html><center>easy pasting to windows apps</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=21">http://vim.sf.net/tip_view.php?tip_id=21</A><BR>

In Vim, the unnamed register is the " register, and the Windows Clipboard is
the * register. This means that if you yank something, you have to yank it to
the * register if you want to paste it into a Windows app. If this is too much
trouble, set the 'clipboard' option to 'unnamed'. Then you always yank to *.

So pasting to windows apps doesn't require prefixing "* :

  set   clipboard=unnamed

</pre></tip> </html> <Tip category="KVim"> <html><center>handle
common typos for :commands</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=22">http://vim.sf.net/tip_view.php?tip_id=22</A><BR>

I frequently hold the shift key for too long when typing, for instance :wq,
and end up with :Wq.  Vim then whines "Not an editor command: Wq"

In my .vimrc, I have taught vim my common typos: command! Q  quit command! W
write command! Wq wq " this one won't work, because :X is already a built-in
command command! X  xit

</pre></tip> </html> <Tip category="KVim">
<html><center>Vim xterm title</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=23">http://vim.sf.net/tip_view.php?tip_id=23</A><BR>

Check out your .vimrc. If 'set notitle' is an entry, comment it out with
a quotation mark ("). Now your xterm should inherit the title from Vim.
e.g. 'Vim - ~/.vimrc'. This can be quite nice when programming and editing
lots of files at the same time.  by [jonasbn@wanadoo.dk]

</pre></tip> </html> <Tip category="KVim"> <html><center>changing
the default syntax highlighting</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=24">http://vim.sf.net/tip_view.php?tip_id=24</A><BR>

     Here are some pointers to the vim documentation.  Notice that the
     mechanism is different in vim 6.0 and vim 5.x.

1. I want *.foo files to be highlighted like HTML files.

:help new-filetype  <A
HREF="http://www.vim.org/html/autocmd.html#new-filetype">http://www.vim.org/html/autocmd.html#new-filetype</A><BR>

2. I want to define a syntax file for *.bar files.  Read the above and also

:help mysyntaxfile  <A
HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR>

3. I want to make a few changes to the existing syntax highlighting.
Depending on the x in 5.x, either read the above and page down a few screens,
or you may be able to skip right to

:help mysyntaxfile-add  <A
HREF="http://www.vim.org/html/syntax.html#mysyntaxfile-add">http://www.vim.org/html/syntax.html#mysyntaxfile-add</A><BR>

4. I want to change some of the colors from their defaults.  Again, read

:help mysyntaxfile  <A
HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR>

</pre></tip> </html> <Tip category="KVim"> <html><center>color
highlighting on telnet (esp w/ SecureCRT)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=25">http://vim.sf.net/tip_view.php?tip_id=25</A><BR>

The following settings in .vimrc will enable color highlighting when using
SecureCRT and may work on other telnet packages. The terminal type should
be selected as ANSI and color enabled.

if !has("gui_running") set t_Co=8 set t_Sf=^[[3%p1%dm set t_Sb=^[[4%p1%dm endif

The ^[ is entered as "&lt;ctrl-v&gt;&lt;esc&gt;"

</pre></tip> </html> <Tip category="KVim"> <html><center>Getting
rid of ^M - mixing dos and unix</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=26">http://vim.sf.net/tip_view.php?tip_id=26</A><BR>

If you work in a mixed environment you will often open files that have ^M's
in them. An example would be this:

------------------------------------------------------------------
import java.util.Hashtable; ^M import java.util.Properties; ^Mimport
java.io.IOException; import org.xml.sax.AttributeList; ^M import
org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException;

/**^M
  * XMLHandler: This class parses the elements contained^M * within a XML
  message and builds a Hashtable^M

[snip] ------------------------------------------------------------------

Notice that some programs are not consistent in the way they insert the line
breaks so you end up with some lines that have both a carrage return and a
^M and some lines that have a ^M and no carrage return (and so blend into
one). There are two steps to clean this up.

1. replace all extraneous ^M:

:%s/^M$//g

BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING "CARROT M"! This
expression will replace all the ^M's that have carriage returns after them
with nothing. (The dollar ties the search to the end of a line)

2. replace all ^M's that need to have carriage returns:

:%s/^M//g

Once again: BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING
"CARROT M"! This expression will replace all the ^M's that didn't have
carriage returns after them with a carriage return.

Voila! Clean file. Map this to something if you do it frequently.

:help ffs - for more info on file formats

thanks to jonathan merz, douglas potts, and benji fisher

</pre></tip> </html> <Tip category="KVim">
<html><center>Convert hex to dec</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=27">http://vim.sf.net/tip_view.php?tip_id=27</A><BR>

when you check the output of objdump, you'll confused by the $0xFFFFFFc
operand, this function translate the hexcamal to decimal.  function! Hex2Dec()
    let lstr = getline(".")  let hexstr = matchstr(lstr, '0x[a-f0-9]+')
    while hexstr != ""
        let hexstr = hexstr + 0 exe 's#0x[a-f0-9]+#'.hexstr."#" let lstr =
        substitute(lstr, '0x[a-f0-9]+', hexstr, "") let hexstr = matchstr(lstr,
        '0x[a-f0-9]+')
    endwhile
endfunction usage: 5,8call Hex2Dec()

</pre></tip> </html> <Tip category="KVim"> <html><center>add a line-number
to every line without cat or awk alike utilities.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=28">http://vim.sf.net/tip_view.php?tip_id=28</A><BR>

With Unix-like environment, you can use cat or awk to generate a line number
easily, because vim has a friendly interface with shell, so everything work
in vim as well as it does in shell.  :%!call -n or :%!awk '{print NR,$0}'

But, if you use vim in MS-DOS, of win9x, win2000, you loss these tookit.
here is a very simple way to archive this only by vim: fu! LineIt()
  exe ":s/^/".line(".")."/"
endf

Well, a sequence composed with alphabet is as easy as above:
  exe "s/^/".nr2char(line("."))."/"

</pre></tip> </html> <Tip category="KVim"> <html><center>reverse
all the line with only 7 keystroke in vim</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=29">http://vim.sf.net/tip_view.php?tip_id=29</A><BR>

:g/^/m0 well, 1. : bring you to command-line mode(also known as ex-mode)
from normal-mode(also known as command mode).  2. g means you'll take an
action through the whole file, generally perform a search, `v' also perform
a search but it match the line not match the canonical expression.  3. /
begins the regular express 4. ^ is a special character respect the start
of a line.  5. the second / ends the regular express and indicate that the
remains is action to do.  6. m means move, `t` and `co' for copy, `d' for
delete 7. 0 is the destination line.

you can use :g/regexp/t$ to filter all lines and pick the match line together
and copy them to the end of the buffer or :g/regexp/y A to put them into a
register(not eax, ebx...)

</pre></tip> </html> <Tip category="KVim">
<html><center>Increasing or decreasing numbers</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=30">http://vim.sf.net/tip_view.php?tip_id=30</A><BR>

To increase a number under or nearest to the right of the cursor, go to
Normal mode and type:
    Ctrl-A

To decrease, type:
    Ctrl-X

Using this in a macro simplifies generating number sequences a lot.

</pre></tip> </html> <Tip category="KVim">
<html><center>Find and Replace</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=31">http://vim.sf.net/tip_view.php?tip_id=31</A><BR>

To find and replace one or more occurences of a given text pattern with a
new text string, use the s[ubstitute] command.

There are a variety of options, but these are what you most probably want:

:%s/foo/bar/g           find each occurance of 'foo' and replace it with
'bar' without asking for confirmation

:%s/foo/bar/gc          find each occurance of 'foo' and replace it with
'bar' asking for confirmation first

:%s/&lt;foo&gt;/bar/gc      find (match exact word only) and replace each
occurance of 'foo' with 'bar'

:%s/foo/bar/gci         find (case insensitive) and replace each occurance of
'foo' with 'bar'

:%s/foo/bar/gcI         find (case sensitive) and replace each occurance of
'foo' with 'bar'

NB: Without the 'g' flag, replacement occurs only for the first occurrence
in each line.

For a full description and some more interesting examples of the substitute
command refer to

:help substitute

See also:

:help cmdline-ranges :help pattern :help gdefault

</pre></tip> </html> <Tip category="KVim"> <html><center>Write
your own vim function(scripts)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=32">http://vim.sf.net/tip_view.php?tip_id=32</A><BR>

compare to C and shell(bash), herein is some vim specifics about vim-script:
1. A function name must be capitalized.
   hex2dec is invalid Hex2dec is valid while in c and shell(bash), both
   lowercase and uppercase is allowed.
2. how to reference the parameters
   fu! Hex2dec(var1, var2)
    let str=a:var1 let str2=a:var2
   you must prefix the parameter name with "a:", and a:var1 itself is read-only
   in c, you reference the parameter directly and the parameter is writable.
3. how to implement variable parameter
   fu! Hex2dec(fixpara, ...)
     a:0 is the real number of the variable parameter when you invoke the
     function, with :Hex2dec("asdf", 4,5,6), a:0=3, and a:1=4 a:2=5 a:3=6
   you can combine "a:" and the number to get the value while i&lt;a:0
     exe "let num=a:".i let i=i+1
   endwhile in c, the function get the real number by checking the additional
   parameter such as printf family, or by checking the special value such
   as NULL
4. where is the vim-library
  yes, vim has its own function-library, just like *.a in c :help functions
5. can I use += or ++ operator?
  Nop, += and ++ (and -=, -- and so on)operator gone away in vim.
6. How can I assign a value to a variables and fetch its value?
   let var_Name=value let var1=var2 like it does in c, except you must use
   let keyword
7. Can I use any ex-mode command in a function?
  As I know, yes, just use it directly, as if every line you type appears
  in the familar :
8. Can I call a function recurse?
  Yes, but use it carefully to avoid infinte call.
9. Can I call another function in a function?
  Course, like C does.
10. Must I compile the function?
   No, you needn't and you can't, just :so script_name, after this you can
   call the function freely.
11. Is it has integer and char or float data type?
   No, like perl, vim script justify the variable type depend upon the context
   :let a=1 :let a=a."asdf" :echo a you'll get `1asdf' :let a=1 :let a=a+2
   :echo a you'll get 3 But it differs from perl.
12. Must I append a `;' in every statement?
   No, never do that.  ; is required in C, and optional in shell for each
   statement in a alone line.  But is forbidden in vim.  if you want combine
   servals statement in one single line, use `|'.  Take your mind that every
   statement appears in function should be valid in ex-mode(except for some
   special statement).

</pre></tip> </html> <Tip category="KVim"> <html><center>toggle
off the line-number when enter on-line help</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=33">http://vim.sf.net/tip_view.php?tip_id=33</A><BR>

I like the line-number for myself editing. But I hate it in on-line help
page because it force the screen wrapped.  :au filetype help :se nonu

</pre></tip> </html> <Tip category="KVim"> <html><center>control
the position of the new window</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=34">http://vim.sf.net/tip_view.php?tip_id=34</A><BR>

:se splitbelow make the new window appears below the current window.
:se splitright make the new window appears in right.(only 6.0 version can
do a vsplit)

</pre></tip> </html> <Tip category="KVim"> <html><center>translate
// style comment to /*  */and vice vesa</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=35">http://vim.sf.net/tip_view.php?tip_id=35</A><BR>

the `|' concatenate servals ex-command in one line.  It's the key to translate
// style comments to /* */ style :g#^s{-}//#s##/*# | s#$#*/#

the `|' keep the current line matchs ^s{-}// to perform s#$#*/

/* ... */ ---&gt; //style :g#/*(.{-})*/#//1#

/* ....
   ....  .....
*/ =====&gt; //......  //......  //......  style: ? Anyone implement it?

</pre></tip> </html> <Tip category="KVim">
<html><center>Using Gnu-info help in vim</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=36">http://vim.sf.net/tip_view.php?tip_id=36</A><BR>

K in normal bring you the man page about the keyword under current cursor.
:nnoremap &lt;F1&gt; :exe ":!info ".expand("&lt;cword&gt;") Now press F1
while the cursor is hold by a keyword such as printf will bring you to
Gnu-info help page :h &lt;F1&gt; :h nnoremap

</pre></tip> </html> <Tip category="KVim"> <html><center>The
basic operation about vim-boolean optionals</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=37">http://vim.sf.net/tip_view.php?tip_id=37</A><BR>

:set number switch the number on :set nonumber switch it off :set invnumber
or :set number!  switch it inverse against the current setting :set number&
get the default value vim assums.

replace number with any legal vim-boolean optionals, they all works well.
for vim-non-boolean optionals :set optional& also works properly.

</pre></tip> </html> <Tip category="KVim"> <html><center>Cursor
one line at a time when :set wrap</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=38">http://vim.sf.net/tip_view.php?tip_id=38</A><BR>

If your tierd of the cursor jumping past 5 lines when :set wrap then add
these mappings to you vimrc file.

nnoremap j gj nnoremap k gk vnoremap j gj vnoremap k gk nnoremap &lt;Down&gt;
gj nnoremap &lt;Up&gt; gk vnoremap &lt;Down&gt; gj vnoremap &lt;Up&gt;
gk inoremap &lt;Down&gt; &lt;C-o&gt;gj inoremap &lt;Up&gt; &lt;C-o&gt;gk

What they do is remap the cursor keys to use there `g' equvilant. See :help gj

</pre></tip> </html> <Tip category="KVim">
<html><center>Undo and Redo</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=39">http://vim.sf.net/tip_view.php?tip_id=39</A><BR>

To undo recent changes, use the u[ndo] command:

u              undo last change (can be repeated to undo preceding commands)
U              return the line to its original state (undo all changes in
current line) CTRL-R         Redo changes which were undone (undo the undo's).

For a full description of the undo/redo commands refer to

:help undo

</pre></tip> </html> <Tip category="KVim">
<html><center>Insert a file</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=40">http://vim.sf.net/tip_view.php?tip_id=40</A><BR>

To insert the contents of a file (or the output of a system command) into
the current buffer, use the r[ead] command:

Examples:

:r foo.txt        inserts the file foo.txt below the cursor

:0r foo.txt       inserts the file foo.txt above the first line

:r !ls            inserts a listing of your directory below the cursor

:$r !pwd          inserts the current working directory below the last line

For more information about the r[ead] command refer to:

:help read

See also:

:help cmdline-ranges :help !cmd

</pre></tip> </html> <Tip category="KVim"> <html><center>Command-history
facilities for Oracle/sqlplus user</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=41">http://vim.sf.net/tip_view.php?tip_id=41</A><BR>

	First of all, thanks Benji fisher,  Stefan Roemer...
and others in vim@vim.org which spend much time to answer questions,
sometimes foolish question asked by someone like me. Without their I can't
get the final solution for my sqlplus work descripted follows.
	As Oracle user known, sqlplus has a very bad
command-line edition environment. It has no command-history, don't support
most of getline facilities. which MySQL and shell does it well.  Even Microsoft
recogonize this point. In Windows2000, doskey is installed by default.
	Below is my vim-solution to sqlplus, which
record the command-history when you use edit(sqlplus builtin command) to
open the editor specified by EDITOR environment variable. It saves the SQL
statement into a standalone file such as .sqlplus.history
	Every time you open the file
afiedt.buf(sqlplus's default command-buffer file), you get two splited windows,
the buffer above is afiedt.buf, the buffer below is .sqlplus.history, you
can see every SQL statement in the windows.  If you want to use SQL statement
in line 5 to replace
 the current command-buffer, just press 5K, then
	:xa to back to you sqlplus. and use / to repeat the command
 saved in command-buffer file called afiedt.buf by default.
	It can't process multi-line SQL statement convinencely.
 Todo this, just use you favorite vim trick to do that:
	fu! VimSQL()
    nnoremap &lt;C-K&gt; :&lt;C-U&gt;
	exe "let linenum=".v:count&lt;CR&gt;:1,$-1d&lt;CR&gt;&lt;C-W&gt;j:exe
	lin enum."y"&lt;CR&gt;&lt;C-W&gt;kP
    let linenum=line("$") 1,$-1w! &gt;&gt; ~/.sqlplus.history e
    ~/.sqlplus.history execute ":$-".(linenum-1).",$m0" %!uniq if
    line("$")&gt;100
      101,$d
    endif b# set splitbelow sp ~/.sqlplus.history au! BufEnter afiedt.buf
endf au BufEnter afiedt.buf call VimSQL()

</pre></tip> </html> <Tip category="KVim">
<html><center>Using marks</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=42">http://vim.sf.net/tip_view.php?tip_id=42</A><BR>

To mark one or more positions in a file, use the m[ark] command.

Examples:

ma	 -    set current cursor location as mark a

'a	 -    jump to beginning of line of mark a

`a	 -    jump to postition of mark a

d'a	 -    delete from current line to line of mark a

d`a	 -    delete from current cursor position to mark a

c'a	 -    change text from current line to line of mark a

y`a	 -    yank text to unnamed buffer from cursor to mark a

:marks	 -    list all the current marks

NB: Lowercase marks (a-z) are valid within one file. Uppercase marks (A-Z),
also called file marks, are valid between files.

For a detailed description of the m[ark] command refer to

:help mark

See also:

:help various-motions

</pre></tip> </html> <Tip category="KVim">
<html><center>Using abbreviations</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=43">http://vim.sf.net/tip_view.php?tip_id=43</A><BR>

To define abbreviations, use the ab[breviate] command.

Examples:

:ab rtfm read the fine manual  -  Whenever you type 'rtfm' followed by a
&lt;space&gt; (or &lt;esc&gt; or &lt;cr&gt;) vim
				  will expand this to 'read the fine manual'.

:ab			       -  list all defined abbreviations

:una[bbreviate] rtfm	       -  remove 'rtfm' from the list of abbreviations

:abc[lear]		       -  remove all abbreviations

NB: To avoid expansion in insert mode, type CTRL-V after the last character
of the abbreviation.

For a detailed description of the ab[breviate] command and some more examples
refer to

:help abbreviations

</pre></tip> </html> <Tip category="KVim">
<html><center>Repeat last changes</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=44">http://vim.sf.net/tip_view.php?tip_id=44</A><BR>

Simple text changes in normal mode (e.g. "dw" or "J") can be repeated with
the "." command.  The last command-line change (those invoked with ":",
e.g. ":s/foo/bar") can be repeated with the "@:" command.

For more informations about repeating single changes refer to:

:help single-repeat

</pre></tip> </html> <Tip category="KVim">
<html><center>Using command-line history</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=45">http://vim.sf.net/tip_view.php?tip_id=45</A><BR>

You can recall previous command lines from a history table by hitting the
&lt;Up&gt; and &lt;Down&gt; cursor keys in command-line mode.  For example,
this can be used to find the previous substitute command: Type ":s" and
then &lt;Up&gt;.

There are separate history tables for the ':' commands and for previous '/'
or '?' search strings.

To display the history of last entered commands or search strings, use the
:his[tory] command:

:his	   -	  Display command-line history.

:his s	   -	  Display search string history.


For a detailed description of the command-line history refer to:

:help cmdline-history

See also:

:help Cmdline-mode

</pre></tip> </html> <Tip category="KVim"> <html><center>Win32
binaries with perl, python, and tcl</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=46">http://vim.sf.net/tip_view.php?tip_id=46</A><BR>

&gt; Does anyone know if windows binaries of vim 5.7 are available with perl
and &gt; python support turned on?

<A
HREF="ftp://vim.sourceforge.net/pub/vim/upload_binaries/">ftp://vim.sourceforge.net/pub/vim/upload_binaries/</A><BR>

<A
HREF="http://vim.sourceforge.net/bin_download/">http://vim.sourceforge.net/bin_download/</A><BR>

</pre></tip> </html> <Tip category="KVim"> <html><center>Swapping
characters, words and lines</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=47">http://vim.sf.net/tip_view.php?tip_id=47</A><BR>

To swap two characters or lines, use the following commands:

xp	 -     delete the character under the cursor and put it afterwards.
	       (In other words, it swaps the characters.)

ddp	 -     delete the current line and put it afterwards.
	       (In other words, it swaps the lines.)

Unfortunately there is no universal solution to swap two words.  You may
try the following ones, but don't expect too much of them:

dawwP	 -     delete the word under the cursor, move forward one word
	       and put it back after the cursor.  (In other words, it swaps
	       the current and following word.)

dawbP	 -     delete the word under the cursor, move backward on word
	       and put it back after the cursor.  (In other words, it swaps
	       the current and preceeding word.)

</pre></tip> </html> <Tip category="KVim">
<html><center>Moving around</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=48">http://vim.sf.net/tip_view.php?tip_id=48</A><BR>

You can save a lot of time when navigating through the text by using
appropriate movements commands. In most cases the cursor keys, &lt;PageUp&gt;
or &lt;PageDown&gt; are NOT the best choice.

Here is a selection of some basic movement commands that hopefully helps
you to acquire a taste for more:

e   - move to the end of a word w   - move forward to the beginning of a
word 3w  - move forward three words b	- move backward to the beginning of
a word 3b  - move backward three words

$	- move to the end of the line &lt;End&gt;   - same as $ 0	-
move to the beginning of the line &lt;Home&gt;	- same as 0

)   - jump forward one sentence (   - jump backward one sentence

}   - jump forward one paragraph {   - jump backward one paragraph

H   - jump to the top of the display M	 - jump to the middle of the display
L   - jump to the bottom of the display

'm  - jump to the beginning of the line of mark m `m  - jump to the location
of mark m

G   - jump to end of file 1G  - jump to beginning of file 50G - jump to line 50

'' - return to the line where the cursor was before the latest jump `` -
return to the cursor position before the latest jump (undo the jump).

%  - jump to corresponding item, e.g. from an open brace to its
     matching closing brace

For some more interesting movement commands (especially those for programmers)
refer to:

:help motion.txt

:help search-commands

</pre></tip> </html> <Tip category="KVim">
<html><center>Switching case of characters</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=49">http://vim.sf.net/tip_view.php?tip_id=49</A><BR>

To switch the case of one or more characters use the "~", "gU" or "gu"
commands.

Examples:

~     -     switch case of character under cursor
	    (in visual-mode: switch case of highlighted text)

3~    -     switch case of next three characters

g~~   -     switch case of current line

U     -     in visual-mode: make highlighted text uppercase

gUU   -     make current line uppercase

u     -     in visual-mode: make highlighted text lowercase

guu   -     make current line lowercase

gUaw  -     make current word uppercase

guaw  -     make current word lowercase

For some more examples refer to

:help ~

See also:

:help simple-change

</pre></tip> </html> <Tip category="KVim">
<html><center>Recovering files</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=50">http://vim.sf.net/tip_view.php?tip_id=50</A><BR>

If your computer has crashed while editing a file, you should be able to
recover the file by typing

      vi -r &lt;filename&gt;

where &lt;filename&gt; is the name of the file you were editing at the time
of the crash.  If you were editing without a file name, give an empty string
as argument:

      vim -r ""

To get a list of recoverable files start vim without arguments:

      vim -r

For more information about file recovery refer to:

:help recovery

</pre></tip> </html> <Tip category="KVim">
<html><center>Entering german umlauts</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=51">http://vim.sf.net/tip_view.php?tip_id=51</A><BR>

To enter german umlauts (or any other of those weired characters) not
available on your keyboard use 'digraphs':

In insert-mode type for example:

     CTRL-K "a

     CTRL-K ^e

which gives an '' and 'e' with a hat.

You can also set the digraph option:

    :set digraph (or :set dg)

With digraph option set you can enter

    " &lt;BS&gt; a

    ^ &lt;BS&gt; e

which gives the same result.

To get a list of currently defined digraphs type

   :dig[graphs]

For more information about defining and using digraphs refer to:

:help digraph.txt

</pre></tip> </html> <Tip category="KVim">
<html><center>Scrolling synchronously</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=52">http://vim.sf.net/tip_view.php?tip_id=52</A><BR>

If you want to bind two or more windows such that when one window is scrolled,
the other windows are scrolled simultaneously, set the 'scrollbind' option
for these windows:

:set scrollbind

When a window that has 'scrollbind' set is scrolled, all other 'scrollbind'
windows are scrolled the same amount, if possible.

For more information about the 'scrollbind' option refer to

:help scoll-binding

</pre></tip> </html> <Tip category="KVim"> <html><center>Better
colors for syntax highlighting</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=53">http://vim.sf.net/tip_view.php?tip_id=53</A><BR>

For syntax highlighting there are two sets of default color maps: One for a
light and another one for a dark background.  If you have a black background,
use the following command to get a better color map for syntax highlighting:

:set background=dark

You have to switch off and on again syntax highlighting to activate the new
color map:

:syntax off :syntax on

For a detailled description of syntax highlighting refer to

:help syntax.txt

See also the Vim syntax support file: $VIMRUNTIME/syntax/synload.vim

</pre></tip> </html> <Tip category="KVim"> <html><center>View
a Java Class File Decompiled thru Vim</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=54">http://vim.sf.net/tip_view.php?tip_id=54</A><BR>

Hi All, Wish u could view a Java Class File using Vim, Well ur query
ends here.  First of all u will need a Java Decompiler to decompile the
Class File.  I would suggest the JAD decompiler by Pavel Kouznetsov <A
HREF="http://www.geocities.com/SiliconValley/Bridge/8617/jad.html">http://www.geocities.com/SiliconValley/Bridge/8617/jad.html</A><BR>

Its a command line decompiler and absolutely free.  U can use any command
line decompiler of ur choice.

Next create a vimscript file called jad.vim as #########################
FILE START ################ augr class au!  au bufreadpost,filereadpost
*.class %!d:jad.exe -noctor -ff -i -p % au bufreadpost,filereadpost
*.class set readonly au bufreadpost,filereadpost *.class set ft=java au
bufreadpost,filereadpost *.class normal gg=G au bufreadpost,filereadpost
*.class set nomodified augr END ######################## FILE END
#####################

Note:- Keep the Jad.exe in a directory with out white spaces.  The -p options
directs JAD to send the output to standard output instead of a .jad file. Other
options are described on the JAD site.

Next add the following line in the .vimrc file.  so jad.vim

Next time u do vim abc.class. Viola u have the source code for abc.class.

NOTE:- I have written the script so as to open the class file read only,
So that u dont accidently modify it.  U can also exted this script to unjar
a jar file and then view each file in the JAR file.  thanks bhaskar Any
suggestions are welcome

</pre></tip> </html> <Tip category="KVim">
<html><center>previous buffer</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=55">http://vim.sf.net/tip_view.php?tip_id=55</A><BR>

One of the keys to vim is buffer management. If I have to use another IDE
that makes me click on a tab every time I want to look at another file I'm
going to go postal.

So of course you know about :ls which lists all the current open buffers. This
gets a little unweildly once you have a full project open so you can also use
:b &lt;any snipit of text&gt; &lt;tab&gt; to complete to an open buffer. This
is really nice because you can type any fragment of a file name and it will
complete to the matching file. (i.e. RequestManager.java can be completed
using "tma"&lt;tab&gt; or "req"&lt;tab&gt; or "r.java"&lt;tab&gt;).

Now for awhile I was also using :bn and :bp which jumps you to the next
and previous buffer respectively. I found I was often frustrated because I
wanted :bp to be the previous buffer I was in, not the previous buffer in
the list. So (drum roll) the reason I wrote this tip was because of:

:b#

jump to the previous buffer you were in. Very very handy. The only thing
nicer are tag, but that's a tip for another time.

:help buffers :help bn :help bp

If anybody knows where to get help on # in this context please add notes.

</pre></tip> </html> <Tip category="KVim"> <html><center>how
to avoid obliterating window layout</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=58">http://vim.sf.net/tip_view.php?tip_id=58</A><BR>

If you take the time to lay out several windows with vim (especially vertically
in version 6), you may be bummed when you hit an errant key and find that
all but what one window disappears.

What happens: while navigating between windows, you hit &lt;C-W&gt;j,
&lt;C-W&gt;k, etc.  At some point you accidently hit &lt;C-W&gt; but then
don't follow with a window command.  Now hitting 'o' to start insert mode
issues a command equivalent to :only, and closes all windows execept for
the one you are in (unless some windows have unsaved changes in them).

How to avoid this: petition the vim-dev mailing list about how :only is
sufficient for the infrequenty use this might get (j/k).

Really: use mapping to disable the &lt;C-W&gt;o functionality; put this in
your .vimrc:

nnoremap &lt;C-W&gt;O :echo "sucker"&lt;CR&gt; nnoremap &lt;C-W&gt;o :echo
"sucker"&lt;CR&gt; nnoremap &lt;C-W&gt;&lt;C-O&gt; :echo "sucker"&lt;CR&gt;

references:

:help :only :help CTRL-W_o

That is all.  Scott

</pre></tip> </html> <Tip category="KVim"> <html><center>Applying
substitutes to a visual block</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=62">http://vim.sf.net/tip_view.php?tip_id=62</A><BR>

If you'd like to apply a substitute, or even any ex command, to a visual-block
selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A
HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim .  Just source
it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim .	Just source
it in,</A><BR> and then press ":B".  On the command line you'll see

:'&lt;,'&gt;BCtrl-V

Just continue with the substitute or whatever...

:'&lt;,'&gt;B s/abc/ABC/g

and the substitute will be applied to just that block of text!

Example: Ctrl-V Select..........|......Type ..................just
the central....|......:B s/abc/ABC/g ..................four
"abc"s..............| ..................----------------....|...-------------
..................abcabcabcabc............|......abcabcabcabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcabcabcabc
 (dots inserted to retain tabular format)

</pre></tip> </html> <Tip category="KVim"> <html><center>Applying
substitutes to a visual block</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=63">http://vim.sf.net/tip_view.php?tip_id=63</A><BR>

If you'd like to apply a substitute, or even any ex command, to a visual-block
selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A
HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim .  Just source
it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim .	Just source
it in,</A><BR> and then press ":B".  On the command line you'll see

:'&lt;,'&gt;BCtrl-V

Just continue with the substitute or whatever...

:'&lt;,'&gt;B s/abc/ABC/g

and the substitute will be applied to just that block of text!

Example: Ctrl-V Select..........|......Type
..................just the central.......|......:B
s/abc/ABC/g ..................four "abc"s.................|
..................---------............|...-------------
..................abcabcabcabc............|......abcabcabcabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcabcabcabc
 (dots inserted to retain tabular format)

</pre></tip> </html> <Tip category="KVim"> <html><center>Always set
your working directory to the file you're editing</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=64">http://vim.sf.net/tip_view.php?tip_id=64</A><BR>

Sometimes I think it's helpful if your working directory is always the same
as the buffer you are editing.	You need to put this in your .vimrc:

function! CHANGE_CURR_DIR()
	let _dir = expand("%:p:h") exec "cd " . _dir unlet _dir
endfunction

autocmd BufEnter * call CHANGE_CURR_DIR()

Doing this will make a "cd" command to your the current buffer each time
you switch to it.  This is actually similar to vimtip#2 but more automatic.

You should see for more details: :help autocmd :help expand :help function

Note: This tip was contributed by somebody on the list a while ago (sorry
for no reference) and it has been extremely helpful to me. Thanks!

</pre></tip> </html> <Tip category="KVim"> <html><center>Insert
line number into the actuall text of the file.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=65">http://vim.sf.net/tip_view.php?tip_id=65</A><BR>

Although :set number will add nice line number for you At time you may wish
to actually place the line numbers into the file. For example on GNU Unix
you can acomplish a simular task using cat -n file &gt; new_file

In VIM you can use the global command to do this

:g/^/exec "s/^/".strpart(line(".")."	", 0, 4)

What this does is run the exec comand on every line that matches /^/ (All)
The exec command taks a string and executes it as if it were typed in.

line(".")."    " -&gt; returns the number of the current line plus four spaces.
strpart("123	", 0, 4) -&gt; returns only the first four characters ("123 ").
"s/^/123 " -&gt; substituts the begining of the line with "123 ".

</pre></tip> </html> <Tip category="KVim"> <html><center>Transfer
text between two Vim 'sessions',</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=66">http://vim.sf.net/tip_view.php?tip_id=66</A><BR>

This one is a one of my favorites from Dr. Chip, and I haven't seen it come
across vim tips yet...

Can use either visual, or marking to denote the text.

" transfer/read and write one block of text between vim sessions " Usage: "
`from' session: "     ma "     move to end-of-block "	  xw " " `to' session:
"     move to where I want block inserted "	xr " if has("unix")
  nmap xr   :r $HOME/.vimxfer&lt;CR&gt; nmap xw
  :'a,.w! $HOME/.vimxfer&lt;CR&gt; vmap xr   c&lt;esc&gt;:r
  $HOME/.vimxfer&lt;CR&gt; vmap xw   :w! $HOME/.vimxfer&lt;CR&gt;
else
  nmap xr   :r c:/.vimxfer&lt;CR&gt; nmap xw   :'a,.w! c:/.vimxfer&lt;CR&gt;
  vmap xr   c&lt;esc&gt;:r c:/.vimxfer&lt;cr&gt; vmap xw
  :w! c:/.vimxfer&lt;CR&gt;
endif

</pre></tip> </html> <Tip category="KVim">
<html><center>Ascii Value</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=67">http://vim.sf.net/tip_view.php?tip_id=67</A><BR>

Sometimes we, the programmers, need the value of a character, don't we?
You can learn the ascii value of a character by pressing g and a keys.(ga)!
It displays the value in dec, hex and octal...

</pre></tip> </html> <Tip category="KVim">
<html><center>Delete key</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=68">http://vim.sf.net/tip_view.php?tip_id=68</A><BR>

Don't worry if your delete key does not work properly.	Just press
&lt;CTRL&gt;-Backspace.  It works under both mode(insert or normal).

</pre></tip> </html> <Tip category="KVim">
<html><center>dot makes life easier</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=69">http://vim.sf.net/tip_view.php?tip_id=69</A><BR>

You can copy and paste the last changes you made in the last insert mode
without using y and p by pressing . (just dot).  Vim memorizes the keys you
pressed and echos them if you hit the dot key.	You must be in command mode
as usual.  It can be helpful...

</pre></tip> </html> <Tip category="KVim">
<html><center>running a command on all buffers</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=70">http://vim.sf.net/tip_view.php?tip_id=70</A><BR>

From Peter Bismuti on the vim list:

How to global search and replace in all buffers with one command?  You need
the AllBuffers command:

:call AllBuffers("%s/string1/string2/g")

"put this in a file and source it function AllBuffers(cmnd)
  let cmnd = a:cmnd let i = 1 while (i &lt;= bufnr("$"))
    if bufexists(i)
      execute "buffer" i execute cmnd
    endif let i = i+1
  endwhile
endfun

":call AllBuffers("%s/foo/bar/ge|update")

Thanks Peter!

</pre></tip> </html> <Tip category="KVim"> <html><center>Transfer
text between two gvim sessions using clipboard</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=71">http://vim.sf.net/tip_view.php?tip_id=71</A><BR>

If you use gvim, you can transfer text from one instance of gvim into another
one using clipboard.  It is convenient to use * (star) register, like this:

In one instance yank two lines into clipboard:
    "*2yy
Paste it in another instance in normal mode:
    "*p
or in insert mode:
    &lt;Ctrl-R&gt;*

</pre></tip> </html> <Tip category="KVim">
<html><center>Remove unwanted empty lines</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=72">http://vim.sf.net/tip_view.php?tip_id=72</A><BR>

Sometimes to improve the readability of the document I insert empty lines,
which will be later removed.  To get rid off them try: :%g/^$/d This will
remove a l l  empty line in the document.  Some other tipps you can find
under www.linuxclass.de/vim.phtml

</pre></tip> </html> <Tip category="KVim">
<html><center>Using vim as calculator</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=73">http://vim.sf.net/tip_view.php?tip_id=73</A><BR>

Basic calculations can done within vim easily by typing (insert-mode): STRG
(=CTRL) + R followed by = then for example 2+2 and hit RETURN the result 4
will be printed in the document.

Some other tipps you can find under www.linuxclass.de/vim.phtml

</pre></tip> </html> <Tip category="KVim"> <html><center>Using
Vim as an outline processor</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=74">http://vim.sf.net/tip_view.php?tip_id=74</A><BR>

With the addition of folding, Vim6 can function as a high performance outline
processor. Simply :set ai and in insert mode use backspace to promote and
tab to demote headlines.

In command mode, &lt;&lt; promotes (n&lt;&lt; to promote multiple lines),
and &gt;&gt; demotes. Also, highlight several headlines and &lt; or &gt;
to promote or demote.

:set foldmethod=indent, and then your z commands can expand or collapse
headline trees, filewide or by the tree.

The VimOutliner GPL distro contains the scripts and configs to easily
configure Vim6 as an outliner, including scripts to create tag files enabling
interoutline hyperlinking.

The VimOutliner project is at <A
HREF="http://www.troubleshooters.com/projects/vimoutliner/index.htm.">http://www.troubleshooters.com/projects/vimoutliner/index.htm.</A><BR>

Steve (Litt) slitt@troubleshooters.com

</pre></tip> </html> <Tip category="KVim"> <html><center>Remap
CAPSLOCK key in Windows 2000 Professional and NT4.0</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=75">http://vim.sf.net/tip_view.php?tip_id=75</A><BR>

If you're Windows 2000 Professional user and got tired to move your hands off
basic row when hitting &lt;ESC&gt; key here the solution (not for Windows 9x.):
remap CapsLock key as &lt;ESC&gt; key. It's located in useful position.  Put
this lines into &lt;EscLock.reg&gt; file and start it in explorer.Reboot.Enjoy.

REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00

To restore you capslock back just delete this entry from Registry and reboot.
And below is remapping &lt;capslock&gt; as &lt;Left Control&gt;:

REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

</pre></tip> </html> <Tip category="KVim">
<html><center>Folding for Quickfix</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=76">http://vim.sf.net/tip_view.php?tip_id=76</A><BR>

The Quickfix mode aims to "speed up the edit-compile-edit cycle" according to
':help quickfix'. After executing ':make' or ':grep' it is possible to skim
through the list of errors/matches and the appropriate source code locations
with, for instance, the ':cnext' command.  Another way to get a quick overview
is to use VIMs folding mode, to fold away all the error-free/match-free
regions.  The script at the end of this message can be used for this
purpose. It is at the moment not elaborate enough to put it up as a 'script';
but it might give someone inspiration to do so.  Big restrictions / bugs are
as follows: 1. Vim Perl interface is required, i.e. the output of ':version'
must contain '+perl' (People with Vim scripting knowledge might fix this)
2. Works only for one file, i.e. the current buffer.  3. It's a quick hack.
Sample usage: (a) edit a file, (b) do ':grep regexp %' to get a quickfix
error list and (c) ':source foldqf.vim' will fold as described Increasing
the value of $CONTEXT gives you more context around the error regions.

Here comes it, it should be 7 lines: ---foldqf.vim cwindow perl $CONTEXT = 0;
perl @A = map { m/\|(\d+)\|/; $1 +0 } $curbuf-&gt;Get(1..$curbuf-&gt;Count());
close normal zD perl sub fold { VIM::DoCommand( $_[0] . ',' . ($_[1]) . "fold"
) if( $_[0] &lt; $_[1] ); } perl $last = 0; for (@A) { fold( $last+1+$CONTEXT,
$_-1-$CONTEXT ); $last = $_; }; VIM::DoCommand(($A[-1]+1+$CONTEXT )
. ',$fold' );

</pre></tip> </html> <Tip category="KVim"> <html><center>Displaying
search results using folds</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=77">http://vim.sf.net/tip_view.php?tip_id=77</A><BR>

A guy I work with told me about a function that an old IBM text editor had
that he said was useful, and that is to create folds in the file after a
search such that every line that is visible contains the search pattern(except
possibly the first). All lines that do not contain the search pattern are
folded up to the last occurence of the pattern or the top of the file.

One use for such a function is to be able to make a quick and dirty api of
a source file.	For example, if working in Java, you could run the function
using the pattern "public|protected|private" and ithe results would be that
only the method headers would be visible (well, close enough).

function! Foldsearch(search)
	normal zE	   "erase all folds to begin with normal G$
	"move to the end of the file let folded = 0	"flag to set when
	a fold is found let flags = "w"    "allow wrapping in the search let
	line1 =  0     "set marker for beginning of fold while search(a:search,
	flags) &gt; 0
		let  line2 = line(".")	"echo "pattern found at line #
		" line2 if (line2 -1 &gt; line1)
			"echo line1 . ":" . (line2-1) "echo "A fold goes here."
			execute ":" . line1 . "," . (line2-1) . "fold"
						let folded = 1	     "at
						least one fold has been found
		endif let line1 = line2     "update marker let flags = "W"
		"turn off wrapping
	endwhile
		" Now create the last fold which goes to the end of the file.
	normal $G let  line2 = line(".")
		"echo "end of file found at line # " line2
	if (line2  &gt; line1 && folded == 1)
		"echo line1 . ":" . line2 "echo "A fold goes here."
		execute ":". line1 . "," . line2 . "fold"
	endif
endfunction

" Command is executed as ':Fs pattern'" command! -nargs=+ -complete=command
Fs call Foldsearch(&lt;q-args&gt;) " View the methods and variables in a
java source file."  command! Japi Fs public\|protected\|private

</pre></tip> </html> <Tip category="KVim">
<html><center>rotating mail signatures</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=78">http://vim.sf.net/tip_view.php?tip_id=78</A><BR>

For people using mutt and vim for mail, the following script will allow
you to insert a new signature (and again and again if you don\'t like the
current one) at the bottom of your mail. This is usefull eg when you don\'t
want to send a potentially offensive quote to someone you don\'t know very
well (or a mailing list), but are too lazy to delete the quote, open your
quotes file, and cut and paste another one in. (I put it here in \'tips\'
and not in \'scripts\' because it is imo too short to be a \'real\' script)

" rotate_sig.vim " Maintainer:	Roel Vanhout &lt;roel@2e-systems.com&gt;
" Version:     0.1 " Last Change: Tuesday, June 12, 2001 " Mapping I use:
" nmap ,r :call RotateSig()&lt;CR&gt; " Usage: " -Make sure you delimit
your sig with '-- ', or adjust the script " -Adjust the last execute to a
command that prints a sig to stdout " Known problems: "   - You'll get an
error message when you're below the last "     '^-- $' in your mail (nothing
bad though - just an not- "	found marker)

function! RotateSig()
    normal mQG execute '?^-- $' execute ':nohl' normal o&lt;ESC&gt; normal
    dG normal &lt;CR&gt; execute 'r !~/bin/autosig ~/.quotes \%' normal `Q
endfunction

</pre></tip> </html> <Tip category="KVim"> <html><center>How to use
:grep to get a clickable list of function names</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=79">http://vim.sf.net/tip_view.php?tip_id=79</A><BR>

The following function will make a :cwindow window with a line per function
in the current C source file. NOTE: It writes the file as a side effect.

Invoke with ':call ShowFunc()' You may want to do :nmap &lt;somekey&gt;
:call ShowFunc()&lt;CR&gt;

function! ShowFunc()

    let gf_s = &grepformat let gp_s = &grepprg

    let &grepformat = '%*\k%*\sfunction%*\s%l%*\s%f %*\s%m' let &grepprg =
    'ctags -x --c-types=f --sort=no -o -'

    write silent! grep % cwindow

    let &grepformat = gf_s let &grepprg = gp_s

endfunc

</pre></tip> </html> <Tip category="KVim"> <html><center>Restore
cursor to file position in previous editing session</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=80">http://vim.sf.net/tip_view.php?tip_id=80</A><BR>

Here's something for your &lt;.vimrc&gt; which will allow you to restore
your cursor position in a file over several editing sessions.  This technique
uses the viminfo option:

Ex. set viminfo='10,\"100,:20,%,n~/.viminfo
    au BufReadPost * if line("'\"") &gt; 0|if line("'\"") &lt;=
    line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

If you're on Unix, the viminfo is probably fine as is (but check up on Vim's
help for viminfo to see if you like the settings above).  For Windows you'll
need to change the "n" suboption to something like

Ex. set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windoz\\_viminfo

This tip is a somewhat improved version of the example given for :he line()
in the Vim on-line documentation.

</pre></tip> </html> <Tip category="KVim">
<html><center>Substitution of characters and lines in VIM is
made far easier with the s and S commands</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=81">http://vim.sf.net/tip_view.php?tip_id=81</A><BR>

Substitute  Characters ----------------------------------- I was just editing
a file that contained the same leading string on many lines.

example:

foo_bar_baz1=a foo_bar_baz1=abc674 foo_bar_baz1=qrs foo_bar_baz1=m1
foo_bar_baz1=bz90 foo_bar_baz1=bc ...

Needing to only substitute a portion of the string, I referred to a VIM
reference card and discovered a command answering my need exactly. The s
command is used to subsitute a certain number of characters. In my example
file above, if I only needed to subsititute the characters foo_bar, I set
the cursor on the first character where I'd like the subsitution to begin
and type 7s. VIM drops the characters foo_bar and goes to insert mode,
waiting for the substitution text.

Substitute Lines ----------------------- After years of using vi and VIM and
always deleting multiple lines in order to replace them, I just discovered
the S command. If you need to subsitute three lines of text, simply type
3S. VIM drops the three lines and goes into insert mode, waiting for the
subsitution text.

</pre></tip> </html> <Tip category="KVim"> <html><center>letting
variable values be overwritten in a script</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=82">http://vim.sf.net/tip_view.php?tip_id=82</A><BR>

this is a simple function i wrote to get the value of a variable from three
different places (in that order):  the current buffer, the global setting
or from the script itself.

this allows me to set a default value for a configuration variable inside my
script and the user to change it on a global level by setting the same variable
with a g: prepended.  then, they can further set it on a per-buffer level by
the the b: mechanism.  one of the examples for this might be my comments script
(not uploaded).  i have a variable in there that determines whether comment
characters (// for java, for example) are placed the beginning of the line or
just before the first-non-blanks in the text.  i set up a default in my script:

let s:comments_hug_start_of_line=0   " comments should hug the text

that's fine as a default, but if i want to overwrite it for vim scripts,
i just put the following in my ftplugin/vim.vim:

let b:comments_hug_start_of_line=1   " vim comments should hug the first
column, always

" tries  to return  the buffer-specific  value of  a variable;	if not
" found,  tries to  return the	global value  -- if  that's not  found "
either, returns the value set in the script itself function! GetVar(varName)
  if (exists ("b:" . a:varName))
    exe "let retVal=b:" . a:varName
  elseif (exists ("g:" . a:varName))
    exe "let retVal=g:" . a:varName
  elseif (exists ("s:" . a:varName))
    exe "let retVal=s:" . a:varName
  else
    retVal=-1
  endif return retVal
endfunction

personally, i never let it get to the -1 state by always having an s: set
with SOME default value.

</pre></tip> </html> <Tip category="KVim"> <html><center>how
to indent (useful for source code)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=83">http://vim.sf.net/tip_view.php?tip_id=83</A><BR>

Here is the most useful vim command that I know of and I'm surprised that
it's not yet in the tips list.

I use the indent features of vim all the time. Basically, it lets you indent
your source code.

SETUP: To make indentation work nicely I have the following in my .vimrc file:
set et set sw=4 set smarttab

these make vim behave nicely when indenting, giving 4 spaces (not tabs)
for each "tabstop".

HOW TO USE: in command mode, == will indent the current line selecting a range
of lines (with shift-v) then == will indent your selection typing a number
then == will indent that many lines, starting from your cursor (you get the
idea, there are many other things you can do to select a range of lines)

Tell me that isn't great?

</pre></tip> </html> <Tip category="KVim"> <html><center>Changing
the behaviour of . to include visual mode</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=84">http://vim.sf.net/tip_view.php?tip_id=84</A><BR>

one of the things i do a lot in vim is to make a change to the beginning or
end of	the line (such as adding  the text '// remove' at  the end of java
debug code).  a quick way of doing  this is to use a  to append the text to
the end of the first line  and then move down one, hit . (repeat last edit),
move down, hit .  etc. etc. the following mapping allows one to  simply
highlight the  region  in  question and  hit  .  -- it	will automatically
execute the . once on each line:

  " allow the . to execute once for each line of a visual selection vnoremap
  . :normal .&lt;CR&gt;

another thing i do a lot is to	record a quick macro in the "a" register
and then play it back a number of  times. while @@ can be used to repeat the
last register used, my recorded macros sometimes use other registers so @@
doesn't necessarily  give me the same results as  @a. also, i have mapped '
to `  because i like to go to the precise  location of my marks -- always --
and never to the  beginning of the line. this  leaves my ` key unused. so:

  " make ` execute the contents of the a register nnoremap ` @a

then, in keeping with the visual . above, i did the same for the ` -- is
thexecutes @a once on each highlighed line.

  vnoremap ` :normal @a&lt;CR&gt;

as an example, say i have the following lines of java code:

      public String m_asdf; public String m_lkhj; public int m_hjkhjkh;

and, for some reason, i need to get the following:

      "asdf" "lkhj" "hjkhjkh"

i record the following into a:

  ^cf_"&lt;ESC&gt;$r"

the ^  is because my  java code is  indented and i  don't want to  go to
column 0 and the &lt;esc&gt; is an actual escape i hit to exit insert mode.

then, i  simply select (visually) the  other lines (only two  in case --
admittedly not an overly useful example) and just hit `.

</pre></tip> </html> <Tip category="KVim"> <html><center>How to mimic
the vim 6.0 plugin feature with older versions</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=85">http://vim.sf.net/tip_view.php?tip_id=85</A><BR>

If you do not have vim 6.0, but would like to mimic the plugins directory
feature then copy and paste this into your vimrc:

exec "source " . substitute(glob($VIM."/plugins/*.vim"), "\n", "\nsource ",
"g")

It will automatically source every vim script file located in the vim/plugins
directory.  Now, to add a new plugin, just drop the script in this directory
and vim will automatically find it.

</pre></tip> </html> <Tip category="KVim"> <html><center>Helps
undo 1 line when entered many</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=86">http://vim.sf.net/tip_view.php?tip_id=86</A><BR>

When U entered text, U cannot undo only 1 line, for example, when U press
"u", all entered in last "insert" text removed.

If U add this line to .vimrc: inoremap &lt;Return&gt; &lt;Return&gt;^O^[
where "^O" or "^[" is 1 char "u" will undo (remove) only 1 line.

</pre></tip> </html> <Tip category="KVim"> <html><center>Get
vim 5.x window in vim 6.x</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=87">http://vim.sf.net/tip_view.php?tip_id=87</A><BR>

The format of the window title in vim 5.x (well, at least for 5.7,.8, for
Win32) used to be VIM - &lt;full filename with path&gt;.  It's not in the
win32 binary of 6.0an that I found.  I want my old way back.

Turns out, all that it takes to get it back is :set title titlestring=VIM\
-\ %F "make sure that the window caption setting is turned on and set caption
to vim 5.x style

Oh, however, one thing I did like about the 6.0 style is that it puts the
word "help" in the title when the current buffer is a help file; so, I just
tacked %h to my titlestring giving:

:set title titlestring=VIM\ -\ %F\ %h "make sure that the window caption
setting is turned on and set caption to vim 5.x style

see also: :he 'titlestring' :he 'statusline'	"for the format for titlestring

</pre></tip> </html> <Tip category="KVim"> <html><center>How
to maximize vim on entry (win32)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=88">http://vim.sf.net/tip_view.php?tip_id=88</A><BR>

Maybe it's just because I have far too small of a monitor, because I can
get distracted while coding if I have other stuff on the screen, or because I
starting using vim on a console, but I definitely like my vim window maximized.
Anyway, sticking the following in your vimrc will always maximize your vim
window on startup.

au GUIEnter * simalt ~x

:he win16-maximized

</pre></tip> </html> <Tip category="KVim"> <html><center>Get more
screen real estate by hidding toolbar and/or menus</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=89">http://vim.sf.net/tip_view.php?tip_id=89</A><BR>

I use gvim over console vim because gvim is much more readable (under Windows).
However, that doesn't mean I want to dedicate screen space to things I'll
never use (i.e. the toolbar and the menus).

Anyway, you can give the following a try if you'd like.

set guioptions-=T "get rid of toolbar set guioptions-=m "get rid of menu

Oh, yeah.  If you decide that you don't really like being without your the
toolbar or menus, issue the following:

set guioptions+=T "bring back toolbar set guioptions+=m "bring back menu

see also: :he 'guioptions

</pre></tip> </html> <Tip category="KVim">
<html><center>Encryption</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=90">http://vim.sf.net/tip_view.php?tip_id=90</A><BR>

You can encrypt your texts by using vim.  :X  prompts for an encryption key.
After writing your key, if you save your document it will be encrypted
and no one else (but you and vim) can read your documents.  If you reopen
the file, VIM will ask for the key.  If you want to disable encryption,
just type :set key= if you forget your key you will lose your document.
So please DO NOT forget your key,


</pre></tip> </html> <Tip category="KVim">
<html><center>Dictionary completions</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=91">http://vim.sf.net/tip_view.php?tip_id=91</A><BR>

This tip will will explain how to use the dictionary completion facilities
provided by vim.  This can be useful if you use vim to type your email,
edit code, etc.

Dictionary completion is one of many search facilites provided by Insert mode
completion.  It allows the user to get a list of keywords, based off of the
current word at the cursor.  This is useful if you are typing a long word
(e.g. acknowledgeable) and don't want to finish typing or don't remember
the spelling.

To start, we must first tell vim where our dictionary is located.  This is done
via the 'dictionary'  option.  Below is an example.  Your location may vary.
See :help 'dictionary'	for hints as to where you should look.

	:set dictionary-=/usr/share/dict/words
	dictionary+=/usr/share/dict/words

Now, to use this list we have to enter insert mode completion.	This is done
by hitting CTRL-X while in insert mode.  Next, you have to specify what you
want to complete.  For dictionaries use CTRL-K.  Once in this mode the keys
CTRL-N and CTRL-P will cycle through the matches.  So, to complete the word
"acknowledgeable" I would do the following in insert mode:

	acknow&lt;CTRL-X&gt;&lt;CTRL-K&gt;&lt;CTRL-N&gt;

It can be cumbersome to type CTRL-X CTRL-K for many different completions.
So, vim gives us a shortcut.  While in insert mode CTRL-N and CTRL-P
will cycle through a predetermined set of completion sources.  By default,
dictionary completion is not a part of this set.  This set is defined by the
'complete' option.  Therefore, we must add dictionary to this as shown below:

	:set complete-=k complete+=k

Now, while in insert mode we can type the following to complete our example:

	acknow&lt;CTRL-N&gt;&lt;CTRL-N&gt;

This shortcut may not save a whole lot of typing.  However, I find that it
requires less hand movement to only worry myself with two key combinations,
rather than 4.

I find that the completion facilites provided by vim save me a *HUGE* amount
of typing.  These savings can be realized in only a short amount of time if
you are editing some code with functions and variables that have long names
with underscores in them.

For more help:
	help ins-completion help compl-dictionary help 'complete' help
	'dictionary' help :set+=

</pre></tip> </html> <Tip category="KVim">
<html><center>Reducing 'doc' directory size</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=92">http://vim.sf.net/tip_view.php?tip_id=92</A><BR>

As everyone knows, the $VIMRUNTIME/doc is increasing rapidly in size. The
directory contained so many plain-text documents that I often compress
them to save my diskspace. With the support of VIM's GZIP plugin,
VIM will automatically uncompress the files when we need to read them.
Here is my procedure: 1.  If you have the source, go to 'runtime/doc'
and edit 'doctags.c', change	   printf("%s\t%s\t/*", p1, argv[0]);  to
printf("%s\t%s.gz\t/*", p1, argv[0]);
     then make. This is to modify the tag, or you'll have to change the
     'tags' file by hand if you don't have doctags.c.
2. Edit the new generated 'tags' file to rename 'help.txt.gz' back to
'help.txt' because it's hard-written in VIM executable binary.
     :% s/help\.txt\.gz/help\.txt/g
3. Copy the new 'tags' to $VIMRNUTIME/doc and run 'gzip *.txt; gunzip help.txt'

On VIM 6.0an, we can reduce the original size (3302k) to 1326k.  I don't
know if this helps, but if someone likes to compress documents... this can
be reffered :)


</pre></tip> </html> <Tip category="KVim"> <html><center>if you use
'highlight search' feature, map a key to :noh</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=93">http://vim.sf.net/tip_view.php?tip_id=93</A><BR>

It is very convenient to use 'hlsearch' option.  However it can be annoying
to have the highlight stick longer than you want it.  In order to run it
off you have to type at least 4 keystrokes, ":noh".  So, it's a good idea
to map this to a key.  I like to map it to control-n.  This is the line I
use in my .vimrc file to do it:

nmap &lt;silent&gt; &lt;C-N&gt; :silent noh&lt;CR&gt;

</pre></tip> </html> <Tip category="KVim"> <html><center>Questions
& Answers about using tags with Vim</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=94">http://vim.sf.net/tip_view.php?tip_id=94</A><BR>

Using tags file with Vim ------------------------ This document gives you
a idea about the various facilities available in Vim for using a tags file
to browse through program source files.  You can read the Vim online help,
which explains in detail the tags support, using :help tagsearch.txt.  You can
also use the help keywords mentioned in this document to read more about a
particular command or option.  To read more about a particular command or
option use, :help &lt;helpkeyword&gt; in Vim.

1. How do I create a tags file?

   You can create a tags file either using the ctags utility or using a
   custom script or utility.

   Help keyword(s): tag

2. Where can I download the tools to generate the tags file?

   There are several utilities available to generate the tags file.
   Depending on the programming language, you can use any one of them.

   1. Exuberant ctags generates tags for the following programming
      language files:

      Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL,
      Eiffel, Fortran, Java, Lisp, Make, Pascal, Perl, PHP, Python, REXX,
      Ruby, S-Lang, Scheme, Tcl, and Vim.

      You can download exuberant ctags from <A
      HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A><BR>

   2. On Unix, you can use the /usr/bin/ctags utility.	This utility
      is present in most of the Unix installations.

   3. You can use jtags for generating tags file for java programs.
      You can download jtags from: <A
      HREF="http://www.fleiner.com/jtags/">http://www.fleiner.com/jtags/</A><BR>

   4. You can use ptags for generating tags file for perl programs.
      You can download ptags from: <A
      HREF="http://www.eleves.ens.fr:8080/home/nthiery/Tags/">http://www.eleves.ens.fr:8080/home/nthiery/Tags/</A><BR>

   5. You can download scripts from the following links for
      generating tags file for verilog files:

	    <A
	    HREF="http://www.probo.com/vtags.htm">http://www.probo.com/vtags.htm</A><BR>
	    <A
	    HREF="http://www.cs.albany.edu/~mosh/Perl/veri-tags">http://www.cs.albany.edu/~mosh/Perl/veri-tags</A><BR>
	    <A
	    HREF="http://www.verilog.net/vrtags.txt">http://www.verilog.net/vrtags.txt</A><BR>

   6. You can download Hdrtag from the following linke:

	    <A
	    HREF="http://www.erols.com/astronaut/vim/index.html#Tags">http://www.erols.com/astronaut/vim/index.html#Tags</A><BR>

      This utility generates tags file for the following programming languages:
      assembly, c/c++, header files, lex, yacc,LaTeX, vim, and Maple V.

   7. You can also use the following scripts which are part of the Vim
      runtime files:

	  pltags.pl - Create tags file for perl code tcltags - Create tags
	  file for TCL code shtags.pl - Create tags file for shell script

   Help keyword(s): ctags

3. How do I generate a tags file using ctags?

   You can generate a tags file for all the C files in the current directory
   using the following command:

	$ ctags *.c

   You can generate tags file for all the files in the current directory
   and all the sub-directories using (this applies only to exuberant ctags):

	$ ctags -R .

   You can generate tags file for all the files listed in a text file named
   flist using (this applies only to exuberant ctags)

       $ ctags -L flist

4. How do I configure Vim to locate a tags file?

   You can set the 'tags' option in Vim to specify a particular tags file.

	set tags=/my/dir/tags

   Help keyword(s): 'tags', tags-option

5. How do I configure Vim to use multiple tags files?

   The 'tags' option can specify more than one tags file.  The tag filenames
   are separated using either comma or spaces.

	set tags=/my/dir1/tags, /my/dir2/tags

6. How do I configure Vim to locate a tags file in a directory tree?

   Note that the following will work only in Vim 6.0 and above.  You can set
   the 'tags' option to make Vim search for the tags file in a directory tree.
   For example, if the 'tags' option is set like this:

	set tags=tags;/

   Vim will search for the file named 'tags', starting with the current
   directory and then going to the parent directory and then recursively to
   the directory one level above, till it either locates the 'tags' file or
   reaches the root '/' directory.

   Help keyword(s): file-searching

7. How do I jump to a tag?

   There are several ways to jump to a tag location.
	1. You can use the 'tag' ex command.  For example,

	       :tag &lt;tagname&gt;

	   will jump to the tag named &lt;tagname&gt;.
	2. You can position the cursor over a tag name and then press
	   Ctrl-].
	3. You can visually select a text and then press Ctrl-] to
	   jump to the tag matching the selected text.
	4. You can click on the tag name using the left mouse button,
	   while pressing the &lt;Ctrl&gt; key.
	5. You can press the g key and then click on the tag name
	   using the left mouse button.
	6. You can use the 'stag' ex command, to open the tag in a new
	   window.  For example,

		:stag func1

	   will open the func1 definition in a new window.
	7. You can position the cursor over a tag name and then press
	   Ctrl-W ].  This will open the tag location in a new window.

   Help keyword(s): :tag, Ctrl-], v_CTRL_], &lt;C-LeftMouse&gt;,
		    g&lt;LeftMouse&gt;, :stag, Ctrl-W_]

8. How do I come back from a tag jump?

   There are several ways to come back to the old location from a tag jump.
	1. You can use the 'pop' ex command.  2. You can press Ctrl-t.
	3. You can click the right mouse button, while pressing the
	   &lt;Ctrl&gt; key.
	4. You can press the g key and then click the right mouse
	   button.

   Help keyword(s): :pop, Ctrl-T, &lt;C-RightMouse&gt;, g&lt;RightMouse&gt;

9. How do I jump again to a previously jumped tag location?

   You can use the 'tag' ex command to jump to a previously jumped tag
   location, which is stored in the tag stack.

   Help keyword(s): tag

10. How do I list the contents of the tag stack?

   Vim remembers the location from which you jumped to a tag in the tag stack.
   You can list the current tag stack using the 'tags' ex command.

   Help keyword(s): :tags, tagstack

11. How do I jump to a particular tag match, if there are multiple
    matching tags?

    In some situations, there can be more than one match for a tag.
    For example, a C function or definition may be present in more than one
    file in a source tree.  There are several ways to jump to a specific
    tag from a list of matching tags.

	1. You can use the 'tselect' ex command to list all the tag
	   matches.  For example,

		:tselect func1

	  will list all the locations where func1 is defined.  You can then
	  enter the number of a tag match to jump to that location.
	2. You can position the cursor over the tag name and press g]
	   to get a list of matching tags.
	3. You can visually select a text and press g] to get a list
	   of matching tags.
	4. You can use the 'stselect' ex command.  This will open the
	   selected tag from the tag list in a new window.
	5. You can position the cursor over the tag name and press
	   Ctrl-W g] to do a :stselect.

    Help keyword(s): tag-matchlist, :tselect, g], v_g], :stselect,
		     Ctrl-W_g]

12. I want to jump to a tag, if there is only one matching tag,
    otherwise a list of matching tags should be displayed.  How do I do this?

    There are several ways to make Vim to jump to a tag directly, if there
    is only one tag match, otherwise present a list of tag matches.

	1. You can use the 'tjump' ex command.	For example,

		:tjump func1

	   will jump to the definition func1, if it is defined only once.
	   If func1 is defined multiple times, a list of matching tags will
	   be presented.
	2. You can position the cursor over the tag and press g
	   Ctrl-].
	3. You can visually select a text and press g Ctrl-] to jump
	   or list the matching tags.
	4. You can use the 'stjump' ex command.  This will open the
	   matching or selected tag from the tag list in a new window.
	5. You can press Ctrl-W g Ctrl-] to do a :stjump.

    Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump,
		     Ctrl-W_g_Ctrl-]

13. How do browse through a list of multiple tag matches?

    If there are multiple tag matches, you can browse through all of them
    using several of the Vim ex commands.

    1. To go to the first tag in the list, use the 'tfirst' or
       'trewind' ex command.
    2. To go to the last tag in the list, use the 'tlast' ex command.
    3. To go to the next matching tag in the list, use the 'tnext' ex
       command.
    4. To go to the previous matching tag in the list, use the
       'tprevious' or 'tNext' ex command.

    Help keyword(s): :tfirst, :trewind, :tlast, :tnext, :tprevious,
		     :tNext

14. How do I preview a tag?

    You can use the preview window to preview a tag, without leaving the
    original window.  There are several ways to preview a tag:

	1. You can use the 'ptag' ex command to open a tag in the
	   preview window.
	2. You can position the cursor on a tag name and press Ctrl-W
	   } to open the tag in the preview window.
	3. You can use the 'ptselect' ex command to do the equivalent
	   of the 'tselect' ex command in the preview window.
	4. You can use the 'ptjump' ex command to do the equivalent of
	   the 'tjump' ex command in the preview window.
	5. You can position the cursor on the tag and press Ctrl-W g}
	   to do a :ptjump on the tag.

    Help keyword(s): :preview-window, :ptag, Ctrl-W_}, :ptselect,
		     :ptjump, Ctrl-W_g}

15. How do I browse through the tag list in a preview window?

    If there are multiple tag matches, you can browse through all of them
    in the preview window using several of the Vim ex commands.

    1. To go to the first tag in the list, use the 'ptfirst' or
       'ptrewind' ex command.
    2. To go to the last tag in the list, use the 'ptlast' ex command.
    3. To go to the next matching tag in the list, use the 'ptnext' ex
       command.
    4. To go to the previous matching tag in the list, use the
       'ptprevious' or 'ptNext' ex command.

    Help keyword(s): :ptfirst, :ptrewind, :ptlast, :ptnext,
		     :ptprevious, :ptNext

16. How do I start Vim to start editing a file at a given tag match?

    While starting Vim, you can use the command line option '-t' to supply
    a tag name.  Vim will directly jump to the supplied tag location.

    Help keyword(s): -t

17. How do I list all the tags matching a search pattern?

    There are several ways to go through a list of all tags matching a pattern.

	1. You can list all the tags matching a particular regular
	   expression pattern by prepending the tag name with the '/'
	   search character.  For example,

		:tag /&lt;pattern&gt; :stag /&lt;pattern&gt; :ptag
		/&lt;pattern&gt; :tselect /&lt;pattern&gt; :tjump
		/&lt;pattern&gt; :ptselect /&lt;pattern&gt; :ptjump
		/&lt;pattern&gt;

	 2. If you have the 'wildmenu' option set, then you can press
	    the &lt;Tab&gt; key to display a list of all the matching tags
	    in the status bar.	You can use the arrow keys to move between
	    the tags and then use the &lt;Enter&gt; key to select a tag.

	 3. If you don't have the 'wildmenu' option set, you can still
	    use the &lt;Tab&gt; key to browse through the list of matching
	    tags.

    Help keyword(s): tag-regexp, wildmenu

18. What options are available to control how Vim handles the tags
    file?

    You can use the following options to control the handling of tags file
    by Vim:

    1. 'tagrelative' - Controls how the file names in the tags file
		       are treated.  When on, the filenames are relative to
		       the directory where the tags file is present.

    2. 'taglength' -  Controls the number of significant characters
		      used for recognizing a tag.

    3. 'tagbsearch' - Controls the method used to search the tags file
		      for a tag.  If this option is on, binary search is
		      used to search the tags file.  Otherwise, linear search
		      is used.

    4. 'tagstack' - Controls how the tag stack is used.

    Help keyword(s): 'tagrelative', 'taglength', 'tagbsearch',
		     'tagstack'

19. Is it possible to highlight all the tags in the current file?

    Yes.  Read the Vim online help on "tag-highlight".

20. Is it possible to create a menu with all the tags in the current
    file?

    Yes.  It is possible to create a menu with all the tags in the current
    file using a Vim script.  Download the TagsMenu.vim script from the
    following link:

    <A
    HREF="http://members.home.net/jayglanville/tagsmenu/TagsMenu.html">http://members.home.net/jayglanville/tagsmenu/TagsMenu.html</A><BR>

21. Is there a workaround to make the Ctrl-] key not to be treated as
    the telnet escape character?

    The default escape characters for telnet in Unix systems is Ctrl-].
    While using Vim in a telnet session, if you use Ctrl-] to jump to a tag,
    you will get the telnet prompt.  There are two ways to avoid this problem:

    1. Map the telnet escape character to some other character using
       the "-e &lt;escape character&gt;" telnet command line option

    2. Disable the telnet escape character using the "-E" telnet
       command line option.

    Help keyword(s): telnet-CTRL-]

</pre></tip> </html> <Tip category="KVim"> <html><center>How do I pipe
the output from ex commands into the text buffer?</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=95">http://vim.sf.net/tip_view.php?tip_id=95</A><BR>

This is a *request* for a tip.	I need to be able to pipe the output of a
:blah ex command into the vim text buffer for editing.	I wanted to do this
many times for different reasons and could never find a way!

I would just love to be able to do :hi --&gt; textBuffer and examine the output
at my own leasure scrolling up and down and using vim search commands on it.
Same thing for :set all, and other things.  Considering that cut and paste
is horrible in windows, I can't for example do :set guioptions? then cut
and paste!  So I have to retype it, or cut and paste from the help manual.
I really want to be able to pipe the output of ex commands into the text
buffer.  Can someone help me?

</pre></tip> </html> <Tip category="KVim"> <html><center>Cooperation
of Gvim and AutoCad [MTEXT]</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=96">http://vim.sf.net/tip_view.php?tip_id=96</A><BR>

You can - like me :o)  - use gvim, like replacement of internal AutoCad
MTEXT editor. You need switch variable MTEXTED to "gvim" (or maybe fullpath,
something like "c:\vim\vim60aq\gvim" ), and to your _vimrc you can put line:

autocmd BufRead,BufNewFile *.tmp source c:\vim\aacad.vim

And when you edit MTEXT in acad, menu AutoCad will be for your use in gvim
(only in INSERT and VISUAL mode)

[NOTE: Only I can't start gvim like gvim -y (for any other person, not so
accustomed vith gvim) or start gvim from gvim.lnk or gvim.bat (I'am using
windows95) and automatic skip to INSERT mode -latest word star, on end of
script- is without functionality(?) Maybe someone advise me?? ]

Well, script aacad.vim is listed here:

"VIM menu for AutoCad's MTEXT editation "brz;
mailto:brz@centrum.cz;	8. 8. 2001 " Version Mk.I
"--------------------------------------------------------------------------

imenu &AutoCad.Insert.Space \~ vmenu &AutoCad.Insert.Space
&lt;Esc&gt;`&lt;i\~&lt;Esc&gt;% imenu &AutoCad.Insert.Backslash \\
vmenu &AutoCad.Insert.Backslash &lt;Esc&gt;`&lt;i\\&lt;Esc&gt;% imenu
&AutoCad.Insert.Brackets \{\}&lt;Esc&gt;F\i vmenu &AutoCad.Insert.Brackets
&lt;Esc&gt;`&gt;a\}&lt;Esc&gt;`&lt;i\{&lt;Esc&gt;% imenu
&AutoCad.Insert.Paragraph \P vmenu &AutoCad.Insert.Paragraph
&lt;Esc&gt;`&gt;a\P&lt;Esc&gt;%

imenu &AutoCad.-SEP1- :

imenu &AutoCad.Colour.Red \C1; vmenu &AutoCad.Colour.Red
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C1;&lt;Esc&gt;% imenu
&AutoCad.Colour.Yellow \C2; vmenu &AutoCad.Colour.Yellow
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C2;&lt;Esc&gt;% imenu
&AutoCad.Colour.Green \C3; vmenu &AutoCad.Colour.Green
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C3;&lt;Esc&gt;%
imenu &AutoCad.Colour.Cyan \C4; vmenu &AutoCad.Colour.Cyan
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C4;&lt;Esc&gt;%
imenu &AutoCad.Colour.Blue \C5; vmenu &AutoCad.Colour.Blue
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C5;&lt;Esc&gt;% imenu
&AutoCad.Colour.Violet \C6; vmenu &AutoCad.Colour.Violet
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C6;&lt;Esc&gt;%
imenu &AutoCad.Colour.Black \C7; vmenu &AutoCad.Colour.Black
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C7;&lt;Esc&gt;% imenu
&AutoCad.Colour.D_Grey \C8; vmenu &AutoCad.Colour.D_Grey
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C8;&lt;Esc&gt;% imenu
&AutoCad.Colour.L_Grey \C9; vmenu &AutoCad.Colour.L_Grey
&lt;Esc&gt;`&gt;a\C7;&lt;Esc&gt;`&lt;i\C9;&lt;Esc&gt;%

imenu &AutoCad.Font.Arial \fArial; vmenu &AutoCad.Font.Arial
&lt;Esc&gt;`&lt;i\fArial;&lt;Esc&gt;% imenu &AutoCad.Font.Symbol \Fsymbol;
vmenu &AutoCad.Font.Symbol &lt;Esc&gt;`&lt;i\Fsymbol;&lt;Esc&gt;%
imenu &AutoCad.Font.RomanC \Fromanc; imenu &AutoCad.Font.RomanC
&lt;Esc&gt;`&lt;i\Fromanc;&lt;Esc&gt;% imenu &AutoCad.Font.RomanS \Fromans;
vmenu &AutoCad.Font.RomanS &lt;Esc&gt;`&lt;i\Fromans;&lt;Esc&gt;%
imenu &AutoCad.Font.RomanD \Fromand; vmenu &AutoCad.Font.RomanD
&lt;Esc&gt;`&lt;i\Fromand;&lt;Esc&gt;% imenu &AutoCad.Font.RomanT \Fromant;
vmenu &AutoCad.Font.RomanT &lt;Esc&gt;`&lt;i\Fromant;&lt;Esc&gt;%

imenu &AutoCad.Size.0_5x \H0.5x; vmenu &AutoCad.Size.0_5x
&lt;Esc&gt;`&lt;i\H0.5x;&lt;Esc&gt;% imenu &AutoCad.Size.1_5x \H1.5x; vmenu
&AutoCad.Size.1_5x &lt;Esc&gt;`&lt;i\H1.5x;&lt;Esc&gt;% imenu &AutoCad.Size.2x
\H2x; vmenu &AutoCad.Size.2x &lt;Esc&gt;`&lt;i\H2x;&lt;Esc&gt;%
imenu &AutoCad.Size.3x \H3x; vmenu &AutoCad.Size.3x
&lt;Esc&gt;`&lt;i\H3x;&lt;Esc&gt;%

imenu &AutoCad.Effects.Set_Out_1_5 \T1.5; vmenu &AutoCad.Effects.Set_Out_1_5
&lt;Esc&gt;`&gt;a\T1;&lt;Esc&gt;`&lt;i\T1.5;&lt;Esc&gt;% imenu
&AutoCad.Effects.Set_Out_2 \T2; vmenu &AutoCad.Effects.Set_Out_2
&lt;Esc&gt;`&gt;a\T1;&lt;Esc&gt;`&lt;i\T2;&lt;Esc&gt;%

imenu &AutoCad.Effects.-SEP3- : imenu
&AutoCad.Effects.Tilt_15deg \Q15; vmenu &AutoCad.Effects.Tilt_15deg
&lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q10;&lt;Esc&gt;% imenu
&AutoCad.Effects.Tilt_20deg \Q20; vmenu &AutoCad.Effects.Tilt_20deg
&lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q20;&lt;Esc&gt;% imenu
&AutoCad.Effects.Tilt_30deg \Q30; vmenu &AutoCad.Effects.Tilt_30deg
&lt;Esc&gt;`&gt;a\Q0;&lt;Esc&gt;`&lt;i\Q30;&lt;Esc&gt;%

imenu &AutoCad.Effects.-SEP4- : imenu &AutoCad.Effects.Change_Width_0_5x
\W0.5; vmenu &AutoCad.Effects.Change_Width_0_5x
&lt;Esc&gt;`&gt;a\W1;&lt;Esc&gt;`&lt;i\W0.5;&lt;Esc&gt;% imenu
&AutoCad.Effects.Change_Width_2x \W2; vmenu &AutoCad.Effects.Change_Width_2x
&lt;Esc&gt;`&gt;a\W1;&lt;Esc&gt;`&lt;i\W2;&lt;Esc&gt;%

imenu &AutoCad.Effects.-SEP5- : imenu &AutoCad.Effects.Justify_Down \A0;
vmenu &AutoCad.Effects.Justify_Down &lt;Esc&gt;`&lt;i\A0;&lt;Esc&gt;%
imenu &AutoCad.Effects.Justify_Middle \A1; vmenu
&AutoCad.Effects.Justify_Middle &lt;Esc&gt;`&lt;i\A1;&lt;Esc&gt;%
imenu &AutoCad.Effects.Justify_Up \A2; vmenu &AutoCad.Effects.Justify_Up
&lt;Esc&gt;`&lt;i\A2;&lt;Esc&gt;% imenu &AutoCad.Effects.Overlined_Characters
\O\o&lt;Esc&gt;F\i vmenu &AutoCad.Effects.Overlined_Characters
&lt;Esc&gt;`&gt;a\O&lt;Esc&gt;`&lt;i\o&lt;Esc&gt;% imenu
&AutoCad.Effects.Underlined_Characters \L\l&lt;Esc&gt;F\i
vmenu &AutoCad.Effects.Underlined_Characters
&lt;Esc&gt;`&gt;a\l&lt;Esc&gt;`&lt;i\L&lt;Esc&gt;% imenu
&AutoCad.Effects.Index_Top \S^;

imenu &AutoCad.-SEP6- : imenu &AutoCad.Help &lt;CR&gt;&lt;CR&gt;***Quit
Editor: press Alt-F4 and 'No' ***&lt;CR&gt;&lt;CR&gt;

star

</pre></tip> </html> <Tip category="KVim"> <html><center>How
do I add a current time string inside Vim?</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=97">http://vim.sf.net/tip_view.php?tip_id=97</A><BR>

This is a *request* for a tip.	Sometimes (eg. editing HTML pages) I need
to add a timestamp string to my editing buffer.  On UNIX systems, I can use
  :r!date
to get a localized date time string; but on Windows ('date' on Windows will
query the user to input new date) or other platforms which does not have
'date' command, how do I get a timestamp easily?

</pre></tip> </html> <Tip category="KVim"> <html><center>Getting
vim help from mailing lists and newsgroups.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=98">http://vim.sf.net/tip_view.php?tip_id=98</A><BR>

There have been a few "requests for tips" entered into the tips database
lately.  If you have specific questions that aren't answered by the existing
tips, there are a couple of resources that may be more appropriate:

The mailing list vim@vim.org is for vim users.	If you send an email
to vim-help@vim.org, you'll get a message back telling you how
to subscribe, as well as how to request old messages and contact
the list maintainer.  This mailing list is also archived at <A
HREF="http://groups.yahoo.com/group/vim.">http://groups.yahoo.com/group/vim.</A><BR>

The newsgroup comp.editors discusses many different editors, but most of
the traffic is about vim.  When posting, it is appreciated if you include
"vim" in the subject line.  The comp.editors newsgroup is archived at <A
HREF="http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.">http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.</A><BR>

Using the tips database for asking questions is not likely to work well.
For example, if you ask a question titled "Searching for strings in a file"
and I read this site and see that tip, I'm not going to read it if I already
know how to search for strings in a file.  In comp.editors and vim@vim.org,
people expect to find questions from others and are therefore more likely
to see your questions.

After finding the answer to your question, please consider whether it would
make an appropriate tip, and if so, add it to the tips database.

</pre></tip> </html> <Tip category="KVim"> <html><center>How to
tell what syntax highlighting group *that* is!</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=99">http://vim.sf.net/tip_view.php?tip_id=99</A><BR>

Here's a (what should be a one-line) map to help you tell just what syntax
highlighting groups the item under the cursor actually is:

map  &lt;F10&gt;  :echo "hi&lt;"
. synIDattr(synID(line("."),col("."),1),"name") . '&gt; trans&lt;'
. synIDattr(synID(line("."),col("."),0),"name") . "&gt; lo&lt;"
. synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . "&gt;"&lt;CR&gt;

Once known you can override the current highlighting with whatever you want.
If you're debugging a syntax highlighting file (a rare occupation), sometimes
you'll wish to know the entire chain of syntax highlighting.  For that,
check out

<A
HREF="http://www.erols.com/astronaut/vim/vimscript/hilinks.vim">http://www.erols.com/astronaut/vim/vimscript/hilinks.vim</A><BR>

</pre></tip> </html> <Tip category="KVim"> <html><center>Jump to
tag (e.g. help topic) with German keyboard (PC)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=100">http://vim.sf.net/tip_view.php?tip_id=100</A><BR>

You're a newbie in vim and need some ":help"? Well, help.txt reads:

"Jump to a subject:  Position the cursor on a tag between |bars| and hit
CTRL-]."

Unfortunately there is no "]" key on German keyboards. On Win32 try CTRL-+
(Strg-+), on Linux console I use CTRL-AltGr-9 (Strg-AltGr-9).

Kind regards

</pre></tip> </html> <Tip category="KVim"> <html><center>Change automatically
to the directory the file in the current buffer is in</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=101">http://vim.sf.net/tip_view.php?tip_id=101</A><BR>

To change automatically to the directory the file in the current buffer is
in add a line (below)  to the file .vimrc .  The file .vimrc should have
the following if-statement to control the autocmd feature:

  if has("autocmd")

    &lt; ... lot of autocmd stuff ... &gt;

    " Change to the directory the file in your current buffer is in autocmd
    BufEnter * :cd %:p:h

  endif " has("autocmd")

Add the line above the endif and restart vim/gvim.

</pre></tip> </html> <Tip category="KVim"> <html><center>smart
mapping for tab completion</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=102">http://vim.sf.net/tip_view.php?tip_id=102</A><BR>

I'm used to complete words with &lt;tab&gt;, however when editing source
I can't just map that to vim keyword completion because I sometime need to
insert real tabs, since it mostly happen when at the beginning of the line or
after a ; and before a one line comma (java, c++ or perl anyone...) I've come
to find the following really usefull This is how you can map the &lt;tab&gt;
key in insert mode while still being able to use it when at the start of
a line or when the preceding char is not a keyword character.  in a script
file in a plugin directory or in your .vimrc file: first define a function
which returns a &lt;tab&gt; or a &lt;C-N&gt; depending on the context:

function InsertTabWrapper()
      let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k'
	  return "\&lt;tab&gt;"
      else
	  return "\&lt;c-p&gt;"
      endif
endfunction

then define the appropriate mapping: inoremap &lt;tab&gt;
&lt;c-r&gt;=InsertTabWrapper()&lt;cr&gt;

the trick here is the use of the &lt;c-r&gt;= in insert mode to be able to
call your function without leaving insert mode.  :help i_CTRL-R Benoit

</pre></tip> </html> <Tip category="KVim"> <html><center>Move
to next/previous line with same indentation</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=103">http://vim.sf.net/tip_view.php?tip_id=103</A><BR>

When working with Python and other languages which don't use braces, it's
useful to be able to jump to and from lines which have the same indentation
as the line you are currently on.

nn &lt;M-,&gt; k:call search ("^". matchstr (getline (line (".")+ 1),
'\(\s*\)') ."\\S", 'b')&lt;CR&gt;^ nn &lt;M-.&gt; :call search ("^". matchstr
(getline (line (".")), '\(\s*\)') ."\\S")&lt;CR&gt;^

will map Alt-&lt; and Alt-&gt; in Normal mode to upward and downward searching
for lines with the same indent as the current line.

</pre></tip> </html> <Tip category="KVim"> <html><center>using
vim to complement Perl's DBI::Shell</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=104">http://vim.sf.net/tip_view.php?tip_id=104</A><BR>

DBI::Shell is a Perl module that is used as a shell interface to Perl's
popular DBI (database interface) package. Forget your favorite SQL navigation
gui and give this method a shot. This has only been tested in UNIX.

1. run dbish (runs DBI::Shell; installed with DBI::Shell) and connect to any
database 2. in dbish, set /format box 3. enter your query 4. to execute query,
type "/ | vim -"

This runs the query and pipes the output to the standard input of vim. Here
are some follow-up tips: -use gvim instead of vim so a new window will pop
up -set nowrap once in vim -make a syntax highlighting file for me!

-Adam Monsen

</pre></tip> </html> <Tip category="KVim">
<html><center>combining move and scroll</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=105">http://vim.sf.net/tip_view.php?tip_id=105</A><BR>

I sometimes found myself moving down a few lines with j, then scrolling
down about the same number of lines with &lt;C-E&gt; to put the cursor in
roughly the same place as it started.  I decided I wanted to map &lt;C-J&gt;
(and &lt;C-K&gt;, respectively) to the move-and-scroll operation.  First, I did

    :map &lt;C-J&gt; &lt;C-E&gt;j

This was pretty good, but behaved funny at the beginning and end of files.
Then, I realized that &lt;C-D&gt; already combined move and scroll, so I
figured that giving &lt;C-D&gt; a count of 1 would do it:

    :map &lt;C-J&gt; 1&lt;C-D&gt;

Unfortunately, this permanently attaches a count to &lt;C-D&gt; (ugh!),
so I have to undo that:

    :map &lt;C-J&gt; 1&lt;C-D&gt;:set scroll=0&lt;CR&gt;

This has the drawback of not necessarily resetting scroll to its original
value, but since I never change scroll, it's good enough for me.  It would be
nice if there were a version of &lt;C-D&gt; that did not have the side-affect
of changing scroll.

Happy vimming, Andrew

</pre></tip> </html> <Tip category="KVim">
<html><center>Supersimple one-line solution</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=106">http://vim.sf.net/tip_view.php?tip_id=106</A><BR>

Hallo, next solution for _most_simple_ signature rotater: You can
only put one line to your .vimrc || _vimrc: map &lt;Leader&gt;ms :e
c:\sign.txt&lt;CR&gt;ggV/--&lt;CR&gt;k"*xG$a&lt;C-R&gt;&lt;C-O&gt;*&lt;Esc&gt;:w&lt;CR&gt;:bd&lt;CR&gt;G$a&lt;C-M&gt;&lt;Esc&gt;"*P

Must exist file (from eg above) c:\sign.txt, with content: -- first signature
-- second signature -- third signature --

When You finished mail, only call shortcut \ms and 'first signature' will
be insert in your mail. In c:\sign.txt will be first signature pushed
to the end of this file. When You want use other signature, only press
'u' and \ms again (Or You can change \ms to e.g. &lt;F12&gt;, indeed. )
You can change this and append one part like 'basic' from command and
append 'changing' part from .signature file, as you like...  Ok, one
unpleasant thing is here: your signature must not contain '--' (signature
separator)...  Anyhow, I find it useful brz* &lt;brz@centrum.cz&gt; <A
HREF="http://brz.d2.cz/">http://brz.d2.cz/</A><BR>

</pre></tip> </html> <Tip category="KVim">
<html><center>convert enum to string table</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=107">http://vim.sf.net/tip_view.php?tip_id=107</A><BR>

When testing your own C/C++ programs you sometimes wish to have a trace output,
which shows you, which enum value is used.  You can do this by creating
a string table for that enum type, which contains the enum identifyer as
a string.  e.g.  printf ("%s", MyEnumStringTable [ MyEnumVal] );

You can create the complete string table by - marking the lines containing
the complete typedef enum - select menu C/C++.transform enum2Stringtab

You can create string table entries by - marking the lines within the typedef
enum - select menu C/C++.transform enum2String

This makes it easy to keep the enum (on changes) consistent to the string
table.

Add the following lines to your _GVIMRC file: 31amenu C/C++.transform\
enum2Stringtab	       :s#[    ]*\\(\\w\\+\\)#/* \\1   */
"\\1"#&lt;CR&gt;o};&lt;ESC&gt;uOstatic const char* const Names[] =
{&lt;ESC&gt;&lt;CR&gt;/sdfsdf&lt;CR&gt; 31vmenu C/C++.transform\ enum2Stringtab
:s#[	]*\\(\\w\\+\\)#/* \\1	*/	"\\1"#&lt;CR&gt;o};&lt;ESC&gt;uOstatic
const char* const Names[] = {&lt;ESC&gt;&lt;CR&gt;/sdfsdf&lt;CR&gt;

31amenu C/C++.transform\ enum2String	:s#[	]*\\(\\w\\+\\)#/*
\\1   */      "\\1"#&lt;CR&gt;o}&lt;ESC&gt;/sdfsdf&lt;CR&gt; 31vmenu
C/C++.transform\ enum2String	:s#[	]*\\(\\w\\+\\)#/* \\1	*/
"\\1"#&lt;CR&gt;o}&lt;ESC&gt;/sdfsdf&lt;CR&gt;

hint: '/sdfsdf' is added for deactivating search highlighting, ok, you'll
sure find a better way to do this.

</pre></tip> </html> <Tip category="KVim"> <html><center>Toggle
a fold with a single keystroke</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=108">http://vim.sf.net/tip_view.php?tip_id=108</A><BR>

When viewing/editing a folded file, it is often needed to inspect/close
some fold.  To speed up these operation use the following (put in your
$HOME/.vimrc):

" Toggle fold state between closed and opened.	" " If there is no fold at
current line, just moves forward.  " If it is present, reverse it's state.
fun! ToggleFold()
	if foldlevel('.') == 0
		normal! l
	else
		if foldclosed('.') &lt; 0
			. foldclose
		else
			. foldopen
		endif
	endif " Clear status line echo
endfun

" Map this function to Space key.  noremap &lt;space&gt; :call
ToggleFold()&lt;CR&gt;

See :help folding for more information about folding.

</pre></tip> </html> <Tip category="KVim">
<html><center>jump between files</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=109">http://vim.sf.net/tip_view.php?tip_id=109</A><BR>

Often I know I'm likely to edit many files. I run 'vim *.pl' and get a whole
bunch of open files.

To make jumping between files to a pleasure, I defined to mapss:

map &lt;f1&gt; :previous&lt;cr&gt; map &lt;f2&gt; :next&lt;cr&gt;

Press F1 to go back and F2 to go forward.

-- Kirill

</pre></tip> </html> <Tip category="KVim">
<html><center>text-&gt;html table converter.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=110">http://vim.sf.net/tip_view.php?tip_id=110</A><BR>

Below are two functions and a mapping which will convert lines of plain
text into HTML table code.  For example, you have several lines like:
----------------------------------------------- 1 2 3

4 5 6 --------------------------------------------------- by visualizing
all the 7 lines and press &lt;F5&gt;, you can change the text into
&lt;table&gt;&lt;tr&gt;
   &lt;td&gt;1&lt;/td&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;
   &lt;td&gt;4&lt;/td&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt; which will eventually render into a table.  So the
rule is: Every line is a table item, every empty line means starting of a
new table row.

"A text-&gt;html table code converter "By: Wenzhi Liang wzhliang@yahoo.com
"You can distribute/change this file freely as long as you keep the title
area. Thanks

func Table()
	let end=line("'&gt;") let start=line("'&lt;") let i=start

	wh i &lt;= end
		exe ":" . i let e=Empty() if e == 1
			exe "normal I&lt;/tr&gt;&lt;tr&gt;"
		else
			exe "normal I&lt;td&gt;A&lt;/td&gt;&gt;&gt;"
		endif let i=i+1
	endwh

	exe "normal o&lt;/tr&gt;&lt;/table&gt;&lt;&lt;" exe ":" . start exe
	"normal O&lt;table&gt;&lt;tr&gt;&lt;&lt;"
endfunc

vmap &lt;F5&gt; &lt;ESC&gt;:call Table()&lt;CR&gt;

func Empty()
	let line_nr= line (".")  let a=getline ( line_nr ) let m=match(a,
	"\\S") if m == -1
		return 1
	else
		return 0
	endif
endfunc

</pre></tip> </html> <Tip category="KVim"> <html><center>Printing with
syntax highlighting independent of your normal highlighting</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=111">http://vim.sf.net/tip_view.php?tip_id=111</A><BR>

I have found it undesirable to use :hardcopy directly because it uses the
current syntax highlighting to determine how to print the text.  For example,
I like to print comments in italics, but I don't like italic fonts on the
screen. This tip will show you how to set up a colorscheme for printing and
use it only when you print.

I copied an existing colorscheme to ~/.vim/colors/print.vim, and changed
all the lines like this:

  highlight Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20
to this:
  highlight clear Normal

Then I set the syntax groups how I wanted them to be printed on the printer:

  highlight Comment	   term=italic	  cterm=italic	  gui=italic highlight
  Constant	 term=bold	cterm=bold	gui=bold etc....

I then defined the following command in my .vimrc file:

command! -nargs=* Hardcopy call DoMyPrint("&lt;args&gt;")

And, finally, I defined this function in my .vimrc:

function DoMyPrint(args)
    let colorsave=g:colors_name color print exec "hardcopy ".a:args exec
    'color '.colorsave
endfunction

After this is complete, you can do:
   :Hardcopy &gt; /tmp/out.ps
or just
   :Hardcopy
(Note the capital H)

</pre></tip> </html> <Tip category="KVim"> <html><center>Back
and forth between indented lines again</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=112">http://vim.sf.net/tip_view.php?tip_id=112</A><BR>

Paul Wright posted a tip which explained how to jump back and forth between
lines with the same indentation level. I do this a lot, so I came up with
this slightly more comprehensive solution.

The example mappings below work as follows:

[l and ]l jump to the previous or the next line with the same indentation
level as the one you're currently on.

[L and ]L jump to the previous or the next line with an indentation level
lower than the line you're currently on.

These movements also work in visual mode and (only as of one of the 6.0 alpha
versions) in operator pending mode, meaning that you can do a d]l. The motion
is specified as being exclusive when in operator pending mode.

When might you use this? If you're writing programs in Python, Haskell,
or editing XML files, they will be very useful. E.g. in XML you can jump to
the outer enclosing tag, or the next matching tag. I use it for practically
anything I edit, so it's not limited to this.

" " NextIndent() " " Jump to the next or previous line that has the same level
or a lower " level of indentation than the current line.  " " exclusive (bool):
true:  Motion is exclusive "			 false: Motion is inclusive "
fwd (bool):	    true:  Go to next line "			 false: Go to
previous line " lowerlevel (bool):  true:  Go to line with lower indentation
level "			    false: Go to line with the same indentation level
" skipblanks (bool):  true:  Skip blank lines "			    false:
Don't skip blank lines

function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
	let line = line('.')  let column = col('.')  let lastline = line('$')
	let indent = indent(line) let stepvalue = a:fwd ? 1 : -1

	while (line &gt; 0 && line &lt;= lastline)
		let line = line + stepvalue if (    ! a:lowerlevel &&
		indent(line) == indent ||
				\ a:lowerlevel && indent(line) &lt; indent)
			if (! a:skipblanks || strlen(getline(line)) &gt; 0)
				if (a:exclusive)
					let line = line - stepvalue
				endif exe line exe "normal " column . "|"
				return
			endif
		endif
	endwhile
endfunc

" Moving back and forth between lines of same or lower indentation.
nnoremap &lt;silent&gt; [l :call NextIndent(0, 0, 0, 1)&lt;cr&gt;
nnoremap &lt;silent&gt; ]l :call NextIndent(0, 1, 0, 1)&lt;cr&gt;
nnoremap &lt;silent&gt; [L :call NextIndent(0, 0, 1, 1)&lt;cr&gt;
nnoremap &lt;silent&gt; ]L :call NextIndent(0, 1, 1, 1)&lt;cr&gt; vnoremap
&lt;silent&gt; [l &lt;esc&gt;:call NextIndent(0, 0, 0, 1)&lt;cr&gt;m'gv''
vnoremap &lt;silent&gt; ]l &lt;esc&gt;:call NextIndent(0, 1, 0,
1)&lt;cr&gt;m'gv'' vnoremap &lt;silent&gt; [L &lt;esc&gt;:call NextIndent(0, 0,
1, 1)&lt;cr&gt;m'gv'' vnoremap &lt;silent&gt; ]L &lt;esc&gt;:call NextIndent(0,
1, 1, 1)&lt;cr&gt;m'gv'' onoremap &lt;silent&gt; [l :call NextIndent(0, 0, 0,
1)&lt;cr&gt; onoremap &lt;silent&gt; ]l :call NextIndent(0, 1, 0, 1)&lt;cr&gt;
onoremap &lt;silent&gt; [L :call NextIndent(1, 0, 1, 1)&lt;cr&gt; onoremap
&lt;silent&gt; ]L :call NextIndent(1, 1, 1, 1)&lt;cr&gt;

</pre></tip> </html> <Tip category="KVim"> <html><center>Translator
in vim (Windows solution)</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=113">http://vim.sf.net/tip_view.php?tip_id=113</A><BR>

Hallo, today I found script "translate.vim", but on Windows this will be
probably difficult to run it (maybe with Cygwin is it possible). I've simpler
solution of keymap for vim interlacing to dictionary: Must exist file with
vocabulary (e.g. "an-cs.txt"), which is called for word under cursor. In
'normal' is only displayed window with translations, in 'insert' is word
under cursor deleted and is insert selected form of word from translantion
window (select it by mouse and than press right button: It works fine on
W2k). Key _F12_ is looking for "word", shifted _S-F12_ is looking for
"pattern".  For windows is needed agrep, which is localy placed on <A
HREF="http://www.tgries.de/agrep/index.html">http://www.tgries.de/agrep/index.html</A><BR>

map &lt;F12&gt; b"*yw&lt;Esc&gt;:! c:/bin/agrep -wih
&lt;C-R&gt;* "c:/dict/an-cs.txt"&lt;CR&gt; imap &lt;F12&gt;
&lt;Esc&gt;b"*yw&lt;Esc&gt;:! c:/bin/agrep -wih &lt;C-R&gt;*
"c:/dict/an-cs.txt"&lt;CR&gt;dwi &lt;C-R&gt;* map &lt;S-F12&gt;
b"*yw&lt;Esc&gt;:! c:/bin/agrep -ih &lt;C-R&gt;* "c:/dict/an-cs.txt"&lt;CR&gt;
imap &lt;S-F12&gt; &lt;Esc&gt;b"*yw&lt;Esc&gt;:! c:/bin/agrep -ih &lt;C-R&gt;*
"c:/dict/an-cs.txt"&lt;CR&gt;dwi &lt;C-R&gt;*

brz* &lt;brz@centrum.cz&gt;

</pre></tip> </html> <Tip category="KVim">
<html><center>Browsing by  paragraph</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=114">http://vim.sf.net/tip_view.php?tip_id=114</A><BR>

It can be done by reaching the blank lines in up and down directions just
by pressing

{    ----  For going to the blank line above the paragraph }	----  For
going to the blank line below the paragraph

</pre></tip> </html> <Tip category="KVim">
<html><center>Browsing by  paragraph</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=115">http://vim.sf.net/tip_view.php?tip_id=115</A><BR>

It can be done by reaching the blank lines in up and down directions just
by pressing

{    ----  For going to the blank line above the paragraph }	----  For
going to the blank line below the paragraph

</pre></tip> </html> <Tip category="KVim"> <html><center>Search all
occurances of the word under cursor in all the open files</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=116">http://vim.sf.net/tip_view.php?tip_id=116</A><BR>

Sometimes it is useful to know all the occurances of the word under cursor in
all the open files. This can be done by pressing [I ( bracket and capital I )
. it shows the results found in the command window.

</pre></tip> </html> <Tip category="KVim"> <html><center>FAST
SEARCH ACROSS THE PROJECT</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=117">http://vim.sf.net/tip_view.php?tip_id=117</A><BR>

Searching for a word across the project wastes most of the
developres time, which can be avoided by the use of GNU Id_utils
with VIM.  The procedure needs to be followed is as follows:
download GNU idutils 3.2d (mkid,lid,fid,fnid,xtokid) from <A
HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR>

uncompress and store these files in the directory from where vim is running.

goto the top level directory of the project, and run mkid, it will create ID
file in that directory (As it is time consuming process, so be patient). copy
this file ID to the directory from where vim is running.

USAGE:

Put these lines in your .vimrc:

	map _u :call ID_search()&lt;Bar&gt;execute "/\\&lt;" . g:word
	. "\\&gt;"&lt;CR&gt; map _n :n&lt;Bar&gt;execute "/\\&lt;" . g:word
	. "\\&gt;"&lt;CR&gt;

	function ID_search()
	  let g:word = expand("&lt;cword&gt;") let x = system("lid --key=none
	  ". g:word) let x = substitute(x, "\n", " ", "g") execute "next " . x
	endfun

To use it, place the cursor on a word, type "_u" and vim will load the file
that contains the word.  Search for the next ocurance of the word in the
same file with "n".  Go to the next file with "_n".

The mapping of "_u" and "_n" can be done to some other key as per your
preference but I use ^K and ^L for this purpose.

</pre></tip> </html> <Tip category="KVim"> <html><center>Configuring
gVim as Internet Explorer 'View Source' editor</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=118">http://vim.sf.net/tip_view.php?tip_id=118</A><BR>

Within the registry, you can specify the source editor to be used by Internet
Explorer when {View|Source} is selected. Unfortunately, you can't specify a
quoted filename argument here, i.e. "%1". The editor specified is supposed
to handle filenames which contain spaces. This will cause problems for
Vim because Vim treats each space as an argument separator. If an unquoted
filename contains spaces, Vim treats the filename as multiple arguments and
will open multiple files instead of one. To workaround this problem a quoted
filename has to be passed to Vim. This can be done by creating the following
Visual Basic Script file gVim.vbs:

'--- gVim.vbs -----------------------------------------------------------------
'function: Start gvim, combining multiple arguments to single file argument.
'changes:  20010905: Quoted 'oWShell.Run' filename argument, allowing spaces.
'	   20010518: Created.  'author:   Freddy Vulto &lt;fvu@fvu.myweb.nl&gt;

  ' Making variable declaration mandatory
option explicit

dim oWShell, sArg, sFile

  ' Create script object
set oWShell = CreateObject("wscript.shell")
  ' Loop through arguments
for each sArg in wscript.arguments
    ' Add argument to filename
  sFile = sFile & sArg & " "
next
  ' Remove excess space
sFile = Trim(sFile)
  ' Run Vim with file argument.  Additional arguments: ' -R: View file
  readonly ' -c "set syntax=html": Use HTML syntax-highlighting '    NOTE:
  Use "-c ""set ft=html""" to make it work for Vim v6.
oWShell.Run _
  """D:\Programs\Vim\Vim58\gvim.exe """ & _ "-R """ & sFile & """ " & _
  "-c ""set syntax=html"""

  ' Destroy script object
set oWShell = NOTHING

The source editor now can be specified by adding the following key to the
registry:

HKEY_LOCAL_MACHINE |- Software
   |- Microsoft
      |- Internet Explorer
	 |- View Source Editor
	    |- Editor Name	 (Default) = D:\Programs\Vim\gvim.vbs

Freddy Vulto &lt;fvu@fvu.myweb.nl&gt; <A
HREF="http://fvu.myweb.nl/Projects/Vim/Web/vim.htm">http://fvu.myweb.nl/Projects/Vim/Web/vim.htm</A><BR>

</pre></tip> </html> <Tip category="KVim">
<html><center>Explorer startup and shutdown</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=119">http://vim.sf.net/tip_view.php?tip_id=119</A><BR>

I really like the new explorer window, but I wanted it to function a little
more seemlessly in the editor.	The following code does two things.  First,
the explorer is started when vim is started.   I also noticed and fixed
that the explorers size is not equal to the window size, hence the strange
behavior when popping between two windows.  The other major function of
the code is to close the explorer when it's the only window that's left.
I'd actually like to take this a step further and close the window if the
last _document_ window is closed.  I'd prefer that multiple explorers or help
windows don't keep the application running - only having a file open keeps the
application running.  But I didn't see an easy way to do this... anyone else?

BTW, thank you Bram for the help figuring this out.

Code (which currently lives in my _vimrc):

" FILE BROWSER STARTUP func OpenFileWindow()
	" :runtime plugin/*.vim		" this would be useful if you were
	calling this
				"   function from the .vimrc directly
	let g:explDetailedList=1	" show size and date by default let
	g:explVertical=1	    " Split vertically let g:explStartRight=0
	" Put new explorer window to the left of the current window :Sexplore
	set nonu set winwidth=15	 " Make the width of the window match
	the explorer setting "let g:explVertical=0	     " Split vertically
	doautocmd fileExplorer BufEnter " Forces the directory refresh to
	occur :winc l		      " change to the document window
endfunc

func CloseIfLast()
	if exists("b:completePath")	" this is how I determine that I'm
	in an explorer window
		let n = winnr() wincmd p if n == winnr()
			quit	" quit the window
		endif wincmd p
	endif
endfunc

if has("autocmd")
	if !exists("rudyautocommands")
		let rudyautocommands = 1 autocmd VimEnter * call
		OpenFileWindow() autocmd WinEnter * call CloseIfLast()

	endif
endif

</pre></tip> </html> <Tip category="KVim"> <html><center>Compiling
Java with Sun JDK (javac) within VIM</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=120">http://vim.sf.net/tip_view.php?tip_id=120</A><BR>

The $VIMRUNTIME/compiler has 'jikes.vim', but there's nothing for traditional
Sun JDK(javac), so I tried (Only tested on Win 2000):

" Vim Compiler File    javac.vim " Compiler:	 Sun/IBM JDK: Javac

if exists("current_compiler")
  finish
endif let current_compiler = "javac"

" Javac defaults to printing output on stderr and no options can convert,
so we have to set 'shellpipe' setlocal shellpipe=2&gt; " 2&gt; works on Win
NT and UNIX setlocal makeprg=javac\ #&lt;.java setlocal errorformat=%f:%l:%m
" Sorry I'm not familiar with 'errorformat', so I set it very simple.

</pre></tip> </html> <Tip category="KVim"> <html><center>Using
vim as a syntax-highlighting pager</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=121">http://vim.sf.net/tip_view.php?tip_id=121</A><BR>

If you want to use Vim's syntax highlighting in a "more"-style pager, here's
one way to set it up:

First, create a vimrc like the following -- I called mine ~/.vimrc.more

---8&lt;---cut here---8&lt;--- " No compatibility -- necessary for mappings
to work.  set nocompatible

" Status line set laststatus=0 set cmdheight=1 set nomodifiable        "
Only in version 6.0 set readonly

" Syntax colouring -- lines taken from syntax.txt discussion on colour xterms.
" See ':help color-xterm'. Use appropriate lines for your own set-up.
if has("terminfo")
    set t_Co=16 set t_Sf=[3%p1%dm set t_Sb=[4%p1%dm
else
    set t_Co=16 set t_Sf=[3%dm set t_Sb=[4%dm
endif " My xterms have a navy-blue background, so I need this line too.
set background=dark " Turn syntax on syntax on

" Key bindings.  nmap b &lt;C-B&gt;&lt;C-G&gt; nmap q :q&lt;CR&gt; " To
type the following line, type *two* C-V's followed by two spaces. This "
is how you map the spacebar.  nmap ^V  &lt;C-F&gt;&lt;C-G&gt; ---8&lt;---cut
here---8&lt;---

Then, to use this .vimrc, add an alias. If you're using tcsh, the syntax
will be something like:

alias vmore "vim -u ~/.vimrc.more"

Then you can type "vmore [filename]" to view a file in this "pager". Spacebar
will move down, 'b' will move back up, and 'q' quits. You can add mappings
for other keys if you want to, also.

</pre></tip> </html> <Tip category="KVim"> <html><center>Skip
blank lines when folding text.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=122">http://vim.sf.net/tip_view.php?tip_id=122</A><BR>

I love the text folding capabilities of vim.  I didn't like that it would
display the first line of the range as the "title" for the fold.  I like
to write my comments with the "/*" on a line by itself.  So I wrote this
little function that will skip over anything that isn't a character, and
then display whatever it finds after that character.

Just include this in your ~/.vimrc (or ~/.gvimrc):

function GetFirstLineWithChars()
	let line_num = 0 let charline = matchstr(getline(v:foldstart),
	'[a-zA-Z][a-zA-Z ]*') while strlen(charline) == 0
		let line_num = line_num + 1 let charline =
		matchstr(getline(v:foldstart + line_num), '[a-zA-Z][a-zA-Z ]*')
	endw return charline
endfunction set
foldtext='+'.v:folddashes.substitute(GetFirstLineWithChars(),'\\\/\\\/\\\|\\*\\\|\\*\\\|{{{\\d\\=','','g')
set fillchars=fold: hi folded guibg=black guifg=yellow gui=bold

And as an added bonus, for those new to text folding, add this to your .vimrc
file too:

autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent loadview

That way whatever folds you set won't get lost when you quit.  I had that
happen after spending 15 minutes folding up a 3000+ line file.	Happy vimming!

</pre></tip> </html> <Tip category="KVim"> <html><center>use
functionality similar to the * search on multiple files</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=123">http://vim.sf.net/tip_view.php?tip_id=123</A><BR>

The use of star as in vimtip#1 and vimtip#5 is great, here is how to use
this type of search accross a whole directory: Just add the mappings (or
choose different letter combinations): map gr :grep &lt;cword&gt; *&lt;cr&gt;
map gr :grep &lt;cword&gt; %:p:h/*&lt;cr&gt; map gR :grep \b&lt;cword&gt;\b
*&lt;cr&gt; map GR :grep \b&lt;cword&gt;\b %:p:h/*&lt;cr&gt;

mapping one will search for the word under the cursor (like g*) in any of
the files in the current directory mapping two will search for the word
under the cursor (like g*) in any of the files in the same directory as the
current file mapping three will search for the word under the cursor by itself
(i.e. surrounded by word boundary like *) in any of the files in the current
directory mapping four will search for the word under the cursor by itself
(i.e. surrounded by word boundary like *) in any of the files in the same
directory as the current file

Benoit

</pre></tip> </html> <Tip category="KVim">
<html><center>Number a group of lines</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=124">http://vim.sf.net/tip_view.php?tip_id=124</A><BR>

Below is a way to number a set of lines.  Here is an exaple before and
after snapshot:

apple bob pear tree

1 apple 2 bob 3 pear 4 tree

" Description: " This provides a command and a function.  They both can be
called with or " without a range.  In addition, they can be called with or
without " arguments.  Without a range they operate on the current line.  " "
There are two supported arguments.  They are described below: "     arg1 -&gt;
the number to start at.  The default is one.  This will "	      number
your selected lines sequentially.  The start can be a "		    number,
., $, or, 'x (like getline).  "     arg2 -&gt; Text to append after numbers.
The default is a space.  " " Examples: "     To provide your functionality:
"	  :%Nlist 20 "	       :%call Nlist(20) "     To make a list start at
1: "	     :'&lt;,'&gt;Nlist "	 :'&lt;,'&gt;call Nlist() "	To
number the whole buffer (with it's actual line number): "	  :%Nlist "
:%call Nlist() "     To number a subset of lines with their line number (and
put a '] ' in "     front of every number): "	      :'&lt;,'&gt;Nlist . ]\
"	  :'&lt;,'&gt;call Nlist(".", "] ")

command! -nargs=* -range Nlist &lt;line1&gt;,&lt;line2&gt;call
Nlist(&lt;f-args&gt;) function! Nlist(...) range
    if 2 == a:0
	let start = a:1 let append = a:2
    elseif 1 == a:0
	let start = a:1 let append = " "
    else
	let start = 1 let append = " "
    endif

    " try to work like getline (i.e. allow the user to pass in . $ or 'x)
    if 0 == (start + 0)
	let start = line(start)
    endif

    exe a:firstline . "," . a:lastline
    . 's/^/\=line(".")-a:firstline+start.append/'
endfunction

</pre></tip> </html> <Tip category="KVim">
<html><center>Auto commenting for "}"</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=125">http://vim.sf.net/tip_view.php?tip_id=125</A><BR>

I always wanted a script that would auto-comment the end of a conditional
block.	So, I wrote one.  This function searches for the previous matching
"{", grabs the line, and inserts it as a comment after the "}".  If there
is no previous matching "{", it inserts nothing.

So...

    if (test){

will generate:
    } // if (test)

This is obviously not work if you use a different style.  If you use

   if (test) {

then substituting 'getline(".")', use  'getline(line(".") - 1)' should work.

Put the following in your .vimrc: au BufNewFile,BufRead *.c,*.cc,*.C,*.h
imap } &lt;ESC&gt;:call CurlyBracket()&lt;CR&gt;a

function CurlyBracket()
  let l:my_linenum = line(".")	iunmap } sil exe "normal i}" imap }
  &lt;ESC&gt;:call CurlyBracket()&lt;CR&gt; let l:result1 =  searchpair('{',
  '', '}', 'bW') if (result1 &gt; 0)
    let l:my_string = substitute(getline("."), '^\s*\(.*\){', '\1', "")
    sil exe ":" . l:my_linenum sil exe "normal a //" . l:my_string
  endif
endfunction

</pre></tip> </html> <Tip category="KVim"> <html><center>how do
I get rid of that bold stuff with my xterm?</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=126">http://vim.sf.net/tip_view.php?tip_id=126</A><BR>

Having problems setting up your syntax highlighting because everything is
coming up in bold?

You're probably using an 8 color xterm and setting up highlighting lines such
as  hi Normal ... ctermfg=green .  The solution: use numbers! 0=black, 1=red,
2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, and 7=white.  Vim tries to use
"bright" colors when its given names (because Windoz machines prefer to use
dim text unless its been made bold).

Read more about it under :help highlight-ctermfg .

</pre></tip> </html> <Tip category="KVim">
<html><center>Preview HTML files quickly</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=127">http://vim.sf.net/tip_view.php?tip_id=127</A><BR>

I've found while writing HTML files that it can become cumbersome when I have
to switch to a web browser, load my page, and move back to VIM regularly to
preview what I've written.  I've come up with the following tricks.

The first one requires that you have lynx (the text-based browser) installed
on your computer (available from <A HREF="http://lynx.isc.org/release/).
If your HTML page is primarily text, with few (if any) images, you can
set up the following function and mapping:">http://lynx.isc.org/release/).
If your HTML page is primarily text, with few (if any) images, you can set
up the following function and mapping:</A><BR>

   function PreviewHTML_TextOnly()
      let l:fname = expand("%:p" ) new set buftype=nofile nonumber exe "%!lynx
      " . l:fname . " -dump -nolist -underscore -width " . winwidth( 0 )
   endfunction

   map &lt;Leader&gt;pt  :call PreviewHTML_TextOnly()&lt;CR&gt;

This will open a new window and display your formatted HTML document in
that window.  Note that bold-face, italics, links, etc. will be lost --
all you will see is the text -- but the "-underscore" parameter to Lynx
causes any text that would have been bold, italicized, or underlined to be
displayed like _this_.

The other trick requires that vim be running on your current machine, and that
you be running a GUI of some sort (X-Windows, Windows, etc.).  You can cause
vim to invoke your favorite browser and have it display the file, like this:
   function PreviewHTML_External()
      exe "silent !mozilla -remote \"openurl(file://" . expand( "%:p" ) . ")\""
   endfunction

   map &lt;Leader&gt;pp :call PreviewHTML_External()&lt;CR&gt;
If you don't use mozilla, you will need to modify the function to use your
preferred browser.

Happy vimming!

</pre></tip> </html> <Tip category="KVim"> <html><center>grep,
diff, patch, idutils, etc. for Windows systems</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=128">http://vim.sf.net/tip_view.php?tip_id=128</A><BR>

     If you use Vim on Windows, and you wish you had some of those nifty
     UNIX command-line tools,
but do not feel like installing all of Cygwin, you
can get many of the most-used tools from Ron Aaron's web site: <A
HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR>
Since Ron is a big Vim fan (see <A
HREF="http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count
on">http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count on</A><BR>
these tools' working well with Vim.  For some hints on how to use them,
read :help :grep :help lid inside Vim.
     Happy Vimming!

</pre></tip> </html> <Tip category="KVim"> <html><center>Removing
automatic comment leaders</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=129">http://vim.sf.net/tip_view.php?tip_id=129</A><BR>

     If you include the "r" flag in the 'formatoptions' option (:help 'fo'
     , :help fo-table ) then the comment leader is inserted
automatically when you start a new line in a comment.  For example, in TeX
the "%" character is the comment leader, and you might type

% This is a tex file.  % The comment leaders on all lines but the first
were generated automatically.  % This is the last line of the comment,
but Vim will insert the comment leader on the next line.  %

You can get rid of the comment leader (along with anything you may already
have typed on the line) without affecting the indent, if any, by typing
"&lt;C-U&gt;" while in Insert mode.

     Related point:  if you want to adjust the indent while in Insert mode,
     you can use "&lt;C-D&gt;" (to Decrease the indent)
or "&lt;C-T&gt;" (to increase it).  In the docs for Vim 6.0, this is described
in the users' manual, :help 30.4 .

</pre></tip> </html> <Tip category="KVim">
<html><center>disabling default ftplugins</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=130">http://vim.sf.net/tip_view.php?tip_id=130</A><BR>

     For an overview of ftplugins (filetype plugins) see

:help ftplugins

If you want to disable all ftplugins, or disable a particular default
ftplugin, see

:help :filetype :help ftplugin-overrule

If you have your own ftplugins, and you want to disable all the default
ones, then do NOT include a check for b:did_ftplugin in your ftplugin files,
and add the line

:autocmd BufEnter * let b:did_ftplugin = 1

to your VIMRC file, BEFORE the ":filetype ftplugin on" line.

</pre></tip> </html> <Tip category="KVim">
<html><center>Scroll alternate window</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=131">http://vim.sf.net/tip_view.php?tip_id=131</A><BR>

This mapping allow you to quickly scroll inactive window when displaying
several windows concurrently.

nmap &lt;silent&gt; &lt;M-Down&gt; :call ScrollOtherWindow("down")&lt;CR&gt;
nmap &lt;silent&gt; &lt;M-Up&gt; :call ScrollOtherWindow("up")&lt;CR&gt;

fun! ScrollOtherWindow(dir)
	if a:dir == "down"
		let move = "\&lt;C-E&gt;"
	elseif a:dir == "up"
		let move = "\&lt;C-Y&gt;"
	endif exec "normal \&lt;C-W&gt;p" . move . "\&lt;C-W&gt;p"
endfun

PS: Original idea and discussion of this tip appeared on vim@vim.org mailing
list, I'm just prettified it a little.

</pre></tip> </html> <Tip category="KVim">
<html><center>window zooming convenience</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=132">http://vim.sf.net/tip_view.php?tip_id=132</A><BR>

i frequently have multiple windows open in vim -- this reduces the number
of lines each window displays -- i almost always have my windows either all
the same size or the current one as big as possible.

the following function can be toggled on or off by typing &lt;Leader&gt;max
(i can do this quite quickly); just change the mapping at the bottom to
something else if you prefer.

this causes the current window to be as big as possible (moving into another
window causes that one to become big) and all the others get very small.
i actually use this ALL the time.  turning it off (by typing the hotkey
sequence again) will cause all windows to have the same height.

"toggles whether or not the current window is automatically zoomed
function! ToggleMaxWins ()
  if exists ('g:windowMax')
    au! maxCurrWin exe "normal \&lt;c-w&gt;=" unlet g:windowMax
  else
    augroup maxCurrWin " au BufEnter * exe "normal
    \&lt;c-w&gt;_\&lt;c-w&gt;\&lt;bar&gt;" " " only max it vertically
    au! BufEnter * exe "normal \&lt;c-w&gt;_" augroup END do maxCurrWin
    BufEnter let g:windowMax=1
  endif
endfunction map &lt;Leader&gt;max :call ToggleMaxWins ()&lt;CR&gt;

</pre></tip> </html> <Tip category="KVim">
<html><center>Windo and Bufdo</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=133">http://vim.sf.net/tip_view.php?tip_id=133</A><BR>

i like bufdo and windo but i don't like the fact that the commands end in
a different window/buffer than from where i executed them.  these versions
(starts with a capital letter) will restore the current window or buffer
when the command's done.

for example, to turn on line numbers everywhere, i use :Windo set nu --
:windo set nu does the trick also but leaves me in a different window than
where i started.

" just like windo but restores the current window when it's done
function! WinDo(command)
  let currwin=winnr() execute 'windo ' . a:command execute currwin . 'wincmd w'
endfunction com! -nargs=+ -complete=command Windo call WinDo(&lt;q-args&gt;)

" just like bufdo but restores the current buffer when it's done
function! BufDo(command)
 let currBuff=bufnr("%") execute 'bufdo ' . a:command execute 'buffer '
 . currBuff
endfunction com! -nargs=+ -complete=command Bufdo call BufDo(&lt;q-args&gt;)

</pre></tip> </html> <Tip category="KVim">
<html><center>View Source in IE6 using VIM</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=134">http://vim.sf.net/tip_view.php?tip_id=134</A><BR>

You can change the "View Source" editor of IE6 by adding the following to
the Windows Registry. Change the path in case you installed VIM in another
location.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source
Editor\Editor Name] @="C:\\vim\\vim60\\gvim.exe"

</pre></tip> </html> <Tip category="KVim">
<html><center>Vim buffer FAQ</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=135">http://vim.sf.net/tip_view.php?tip_id=135</A><BR>

Vim provides various commands and options to support editing multiple buffers.
This document covers some of the questions asked about using multiple buffers
with Vim.  You can get more detailed information about Vim buffer support using
":help windows.txt" in Vim.  You can also use the help keywords mentioned in
this document to read more about a particular command or option.  To read more
about a particular command or option use, ":help &lt;helpkeyword&gt;" in Vim.

1. What is a Vim buffer?
   A buffer is a file loaded into memory for editing.  All opened files
   are associated with a buffer. There are also buffers not associated with
   any file.

   Help keyword(s): windows-intro

2. How do I identify a buffer?
   Vim buffers are identified using a name and a number.  The name of the
   buffer is the name of the file associated with that buffer.	The buffer
   number is a unique sequential number assigned by Vim.  This buffer number
   will not change in a single Vim session.

   Help keyword(s): :buffers

3. How do I create a buffer?
   When you open a file using any of the Vim commands, a buffer is
   automatically created.  For example, if you use the ":edit file" command
   to edit a file, a new buffer is automatically created.

4. How do I add a new buffer for a file to the buffer list without opening
   the file?  You can add a new buffer for a file without opening it, using
   the ":badd" ex command.  For example,

       :badd f1.txt :badd f2.txt

   The above commands will add two new buffers for the files f1.txt and
   f2.txt to the buffer list.

   Help keyword(s): :badd

5. How do I get a list of all the existing buffers?
   You can get a list of all the existing buffers using the ":buffers" or
   ":ls" or ":files" ex command.  This list is called the 'buffer list'.

   In Vim 6.0, to display all the buffers including unlisted buffers, use the
   ":buffers!" or ":ls!" or ":files!" ex command.

   Help keyword(s): :buffers, :ls, :files

6. How do I delete a buffer?
   You can delete a buffer using the ":bdelete" ex command.  You can use either
   the buffer name or the buffer number to specify a buffer.  For example,

       :bdelete f1.txt :bdelete 4

   The above commands will delete the buffer named "f1.txt" and the fourth
   buffer in the buffer list.  The ":bdelete" command will remove the buffer
   from the buffer list.

   In Vim 6.0, when a buffer is deleted, the buffer becomes an unlisted-buffer
   and is no longer included in the buffer list.  But the buffer name and other
   information associated with the buffer is still remembered.	To completely
   delete the buffer, use the ":bwipeout" ex command.  This command will remove
   the buffer completely (i.e. the buffer will not become a unlisted buffer).

   Help keyword(s): :bdelete, :bwipeout

7. How do I delete multiple buffers?
   You can delete multiple buffers in several ways:

   1. Pass a range argument to the ":bdelete" command. For example,

	   :3,5bdelete

      This command will delete the buffers 3, 4 and 5.
   2. Pass multiple buffer names to the ":bdelete" command.  For example,

	   :bdelete buf1.txt buf2.c buf3.h

      This command will delete buf1.txt, buf2.c and buf3.h buffers.  In this
      example, after typing ":bdelete buf", you can press &lt;Ctrl-A&gt;
      to expand all the buffer names starting with 'buf'.

   Help keyword(s): :bdelete, :bwipeout

8. How do I remove a buffer from a window?
   You can remove a buffer displayed in a window in several ways:

   1. Close the window or edit another buffer/file in that window.  2. Use
   the ":bunload" ex command. This command will remove the buffer
      from the window and unload the buffer contents from memory.  The buffer
      will not be removed from the buffer list.

   Help keyword(s): :bunload

9. How do I edit an existing buffer from the buffer list?
   You can edit or jump to a buffer in the buffer list in several ways:

   1. Use the ":buffer" ex command passing the name of an existing buffer
      or the buffer number.  Note that buffer name completion can be used
      here by pressing the &lt;Tab&gt; key.
   2. You can enter the buffer number you want to jump/edit and press the
      Ctrl-^ key.
   3. Use the ":sbuffer" ex command passing the name of the buffer or the
      buffer number.  Vim will split open a new window and open the specified
      buffer in that window.
   4. You can enter the buffer number you want to jump/edit and press the
      Ctrl-W ^ or Ctrl-W Ctrl-^ keys.  This will open the specified buffer
      in a new window.

   Help keyword(s): :buffer, :sbuffer, CTRL-W_^, CTRL-^

10. How do I browse through all the available buffers?
    You can browse through the buffers in the buffer list in several ways:

    1. To jump to the first buffer in the buffer list, use the ":bfirst" or
       ":brewind" ex command.
    2. To jump to the first buffer in the buffer list in a new window, use
       the ":sbfirst" or ":sbrewind" ex command.
    3. To edit the next buffer in the buffer list, use the ":bnext" ex
       command.
    4. To open the next buffer in the buffer list in a new window, use the
       ":sbnext" ex command.
    5. To edit the previous buffer in the buffer list, use the ":bprevious"
       or ":bNext" ex command.
    6. To open the previous buffer in the buffer list in a new window, use
       the ":sbprevious" or ":sbNext" ex command.
    7. To open the last buffer in the buffer list, use the ":blast" ex
       command.
    8. To open the last buffer in the buffer list in a new window, use the
       ":sblast" ex command.

    Help keyword(s): :bfirst, :brewind, :sbfirst, :sbrewind, :bnext,
		     :sbnext, :bprevious, :bNext, :sbprevious, :sbNext,
		     :blast, :sblast

11. How do I open all the buffers in the buffer list?
    You can open all the buffers present in the buffer list using the ":ball"
    or ":sball" ex commands.

    Help keyword(s): :ball, :sball

12. How do I open all the loaded buffers?
    You can open all the loaded buffers in the buffer list using the ":unhide"
    or ":sunhide" ex commands.	Each buffer will be loaded in a separate
    new window.

    Help keyword(s): :unhide, :sunhide

13. How do I open the next modified buffer?
    You can open the next or a specific modified buffer using the ":bmodified"
    ex command.  You can open the next or a specific modified buffer in a
    new window using the ":sbmodified" ex command.

    Help keyword(s): :bmodified, :sbmodified

14. I am using the GUI version of Vim (gvim), is there a simpler way for
    using the buffers instead of the ex commands?  Yes.  In the GUI version of
    Vim, you can use the 'Buffers' menu, which simplifies the use of buffers.
    All the buffers in the buffer list are listed in this menu.  You can
    select a buffer name from this menu to edit the buffer.  You can also
    delete a buffer or browse the buffer list.

    Help keyword(s): buffers-menu

15. Is there a Vim script that simplifies using buffers with Vim?
    Yes.  You can use the bufexplorer.vim script to simplify the process of
    using buffers.  You can download the bufexplorer script from:

	<A
	HREF="http://lanzarotta.tripod.com/vim.html">http://lanzarotta.tripod.com/vim.html</A><BR>

16. Is it possible to save and restore the buffer list across Vim sessions?
    Yes.  To save and restore the buffer list across Vim session, include the
    '%' flag in the 'viminfo' option.  Note that if Vim is invoked with a
    filename argument, then the buffer list will not be restored from the
    last session.  To use buffer lists across sessions, invoke Vim without
    passing filename arguments.

    Help keyword(s): 'viminfo', viminfo

17. How do I remove all the entries from the buffer list?
    You can remove all the entries in the buffer list by starting Vim with
    a file argument.  You can also manually remove all the buffers using the
    ":bdelete" ex command.

18. What is a hidden buffer?
    A hidden buffer is a buffer with some unsaved modifications and is not
    displayed in a window.  Hidden buffers are useful, if you want to edit
    multiple buffers without saving the modifications made to a buffer while
    loading other buffers.

    Help keyword(s): :buffer-!, 'hidden', hidden-buffer, buffer-hidden

19. How do I load buffers in a window, which currently has a buffer with
    unsaved modifications?  By setting the option 'hidden', you can load
    buffers in a window that currently has a modified buffer.  Vim will
    remember your modifications to the buffer.	When you quit Vim, you will be
    asked to save the modified buffers.  It is important to note that, if you
    have the 'hidden' option set, and you quit Vim forcibly, for example using
    ":quit!", then you will lose all your modifications to the hidden buffers.

    Help keyword(s): 'hidden'

20. Is it possible to unload or delete a buffer when it becomes hidden?
    The following works only in Vim 6.0 and above. By setting the 'bufhidden'
    option to either 'hide' or 'unload' or 'delete', you can control what
    happens to a buffer when it becomes hidden.  When 'bufhidden' is set to
    'delete', the buffer is deleted when it becomes hidden. When 'bufhidden'
    is set to 'unload', the buffer is unloaded when it becomes hidden.
    When 'bufhidden' is set to 'hide', the buffer is hidden.

    Help keyword(s): 'bufhidden'

21. How do I execute a command on all the buffers in the buffer list?
    In Vim 6.0, you can use the ":bufdo" ex command to execute an ex command
    on all the buffers in the buffer list.

    Help keyword(s): :bufdo

22. When I open an existing buffer from the buffer list, if the buffer is
    already displayed in one of the existing windows, I want Vim to jump to
    that window instead of creating a new window for this buffer.  How do I
    do this?  When opening a buffer using one of the split open buffer commands
    (:sbuffer, :sbnext), Vim will open the specified buffer in a new window.
    If the buffer is already opened in one of the existing windows, then
    you will have two windows containing the same buffer.  You can change
    this behavior by setting the 'switchbuf' option to 'useopen'.  With this
    setting, if a buffer is already opened in one of the windows, Vim will
    jump to that window, instead of creating a new window.

    Help keyword(s): 'switchbuf'

23. What information is stored as part of a buffer?
    Every buffer in the buffer list contains information about the last
    cursor position, marks, jump list, etc.

24. What is the difference between deleting a buffer and unloading a
    buffer?  When a buffer is unloaded, it is not removed from the buffer list.
    Only the file contents associated with the buffer are removed from memory.
    When a buffer is deleted, it is unloaded and removed from the buffer list.
    In Vim 6, a deleted buffer becomes an 'unlisted' buffer.

    Help keyword(s): :bunload, :bdelete, :bwipeout, unlisted-buffer

25. Is it possible to configure Vim, by setting some option, to re-use the
    number of a deleted buffer for a new buffer?  No.  Vim will not re-use the
    buffer number of a deleted buffer for a new buffer.  Vim will always assign
    the next sequential number for a new buffer.  The buffer number assignment
    is implemented this way, so that you can always jump to a buffer using the
    same buffer number.  One method to achieve buffer number reordering is to
    restart Vim.  If you restart Vim, it will re-assign numbers sequentially
    to all the buffers in the buffer list (assuming you have properly set
    'viminfo' to save and restore the buffer list across vim sessions).

    Help keyword(s): :buffers

26. What options do I need to set for a scratch (temporary) buffer?
    The following works only in Vim 6.0 and above.  You can set the the
    following options to create a scratch (temporary) buffer:

	:set buftype=nofile :set bufhidden=hide :setlocal noswapfile

    This will create a buffer which is not associated with a file, which
    does not have a associated swap file and will be hidden when removed
    from a window.

    Help keyword(s): special-buffers, 'buftype'

27. How do I prevent a buffer from being added to the buffer list?
    The following works only in Vim 6.0 and above. You can prevent a buffer
    from being added to the buffer list by resetting the 'buflisted' option.

	:set nobuflisted

    Help keyword(s): 'buflisted'

28. How do I determine whether a buffer is modified or not?
    There are several ways to find out whether a buffer is modified or not.
    The simplest way is to look at the status line or the title bar.  If the
    displayed string contains a '+' character, then the buffer is modified.
    Another way is to check whether the 'modified' option is set or not.
    If 'modified' is set, then the buffer is modified.	To check the value
    of modified, use

	:set modified?

    You can also explicitly set the 'modified' option to mark the buffer as
    modified like this:

	:set modified

    Help keyword(s): 'modified'

29. How can I prevent modifications to a buffer?
    The following works only in Vim 6.0 and above. You can prevent any
    modification to a buffer by re-setting the 'modifiable' option.  To reset
    this option, use

	:set nomodifiable

    To again allow modifications to the buffer, use:

	:set modifiable

    Help keyword(s): 'modifiable'

30. How do I set options specific to the current buffer?
    The following works only in Vim 6.0 and above.  You can set Vim options
    which are specific to a buffer using the "setlocal" command.  For example,

	:setlocal textwidth=70

    This will set the 'textwidth' option to 70 only for the current buffer.
    All other buffers will have the default or the previous 'textwidth' value.

    Help keyword(s): 'setlocal', local-options

31. How do I define mappings specific to the current buffer?
    The following works only in Vim 6.0 and above.  You can define mappings
    specific to the current buffer by using the keyword "&lt;buffer&gt;"
    in the map command.  For example,

	:map &lt;buffer&gt;  ,w  /[.,;]&lt;CR&gt;

    Help keyword(s): :map-local

32. How do I define abbreviations specific to the current buffer?
    The following works only in Vim 6.0 and above.  You can define
    abbreviations specific to the current buffer by using the keyword
    "&lt;buffer&gt;" in the :abbreviate command.  For example,

	:abb &lt;buffer&gt; FF	for (i = 0; i &lt; ; ++i)

    Help keyword(s): :abbreviate-local

</pre></tip> </html> <Tip category="KVim"> <html><center>Remapping
Alt, Ctrl and Caps in Win2k</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=136">http://vim.sf.net/tip_view.php?tip_id=136</A><BR>

Since I installed Win2K on my laptop, I had been unable to locate a utilitie
that would simply enable me to remap my Crtl Alt and Caps the way I think they
should be and the way they were until MS kill all competition in computing,
that is Crtl on the left of the letter A, Alt to the left bottom of the
letter Z and Caps approximately until the C.

After some research, I came across a tip posted here by juano@mindspring.com. I
tried to make sense of it and then downloaded the MS scan keys map at the
URL he mentionned.

Extrapolating his tip, I wrote this ASCI file that I named keys2000.reg :

Regedit4 [HKey_Local_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard
Layout] "Scancode
Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,3A,00,38,00,38,00,1D,00,1D,00,3A,00,00,00,00

Once you have saved this file, left click on it from Explorer and answer
yes to the prompt "do you want to enter this into the registry".

Reboot and you are done.

A few explanations :04 stands for 3 remappings (Caps lock to Control, Control
to Alt and Alt to Caps Lock) plus the closing one which is always required
(1 remapping would require 02, 2 would require 03, and so on). 3A,00,38
remaps Caps to Left Alt, 38,00,1D remaps Left Alt to Left Ctrl and 1D,00,3A
remaps Left Ctrl to Caps Lock since 3A=Caps, 1D=Left Ctrl and 38=Left Alt.

Based on Juano tip and on this one, I believe a lot of remapping can be done
as long as you keep the separators 00 and remember to add one to the number
of remappings. What I do not know is how far you can extend this instruction
without getting into trouble with the registry. At worst, if you keyboard does
not behave as expected, go into the registry and delete this instruction (be
careful here since it is easy to confuse this instruction with the Keyboard
LayoutS (S for emphasis) which must not be deleted.

Again, thanks to Juano@mindspring.com who got me going and suggested I
post my tip. Took me some time to retrieve the VIM Url but fortunately,
I had printed his tip.

Regards

</pre></tip> </html> <Tip category="KVim">
<html><center>automatically wrap left and right</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=137">http://vim.sf.net/tip_view.php?tip_id=137</A><BR>

I hate it when I hit left (or h) and my screen flickers.  I want it to go up
to the next line.  Ditto fir right (or l).  Below are two functions / mappings
to help with that.  I'm pretty sure that if you remove the &lt;silent&gt;,
then it will work in 5.x...

nnoremap &lt;silent&gt; &lt;Left&gt;  :call WrapLeft()&lt;cr&gt; nnoremap
&lt;silent&gt; &lt;Right&gt; :call WrapRight()&lt;cr&gt;

nnoremap &lt;silent&gt; h	:call WrapLeft()&lt;cr&gt; nnoremap
&lt;silent&gt; l       :call WrapRight()&lt;cr&gt;

function! WrapLeft()
    let col = col(".")

    if 1 == col
	" don't wrap if we're on the first line if 1 == line(".")
	    return
	endif normal! k$
    else
	normal! h
    endif
endfunction

function! WrapRight()
    let col = col(".")	if 1 != col("$")
	let col = col + 1
    endif

    if col("$") == col
	" don't wrap if we're on the last line if line("$") == line(".")
	    return
	endif normal! j1|
    else
	normal! l
    endif
endfunction

</pre></tip> </html> <Tip category="KVim">
<html><center>Getting name of the function</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=138">http://vim.sf.net/tip_view.php?tip_id=138</A><BR>

Hi All,

While browsing code one always needs to know which function you are currently
looking. Getting the name is very painful when the functions are lengthy
and you are currently browsing NOT near to the start of the function. You
can get the function's name by using this simple mapping.

Just place this in your .vimrc.

map _F ma[[k"xyy`a:echo @x&lt;CR&gt;

now _F will display which function you are currently in.

Enjoy the power of Vim -Nitin Raut

PS: The working is as follows, mark the current line with a, jump to the
previous '{' in the first column, go one line up, yank the line in register
x, return to the mark a, echo the value of register x, which is the wanted
function name.

</pre></tip> </html> <Tip category="KVim"> <html><center>=,
LaTeX tables, declarations, etc</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=139">http://vim.sf.net/tip_view.php?tip_id=139</A><BR>

Check out

<A
HREF="http://www.erols.com/astronaut/vim/textab.html">http://www.erols.com/astronaut/vim/textab.html</A><BR>

and see some examples of text alignment (its hopeless to do it here with
proportional fonts).  You'll be able to download textab source, a Windows-based
textab executable, and a scriptfile containing a convenient interface
(ttalign.vim).	The textab program coupled with &lt;ttalign.vim&gt; lets you:

1. align C language statements on their = += -= /= etc symbols 2. align C
language declararations: separate columns for types, *[, variable
   names, initializations (=), and comments (// or /* .. */)
3. align C/C++ language comments (//, /* .. */) 4. align C/C++ language
(ansi) function argument lists 5. align LaTeX tables on their && separators
6. align HTML tables with &lt;/TD&gt;&lt;TD&gt; separators 7. align on
several characters: &lt; ? : | @ ;  (or modify them to handle whatever
   alignment characters you want)

</pre></tip> </html> <Tip category="KVim"> <html><center>tip
using embedded perl interpreter</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=140">http://vim.sf.net/tip_view.php?tip_id=140</A><BR>

When writing scripts using the embedded interpreter available if vim has the
+perl ore +perl/dyn on gives you access to this powerfull and FAST scripting
language (especially fast compared to vim scripts)  there are some gotchas.

First: never embed complex perl command in the body of a vim function this
will be recompiled and evaled each time for a tremendous loss of time.instead
to it like this

perl &lt;&lt; EOF sub mySub {
  #some usefull perl stuff
} EOF

function! MyFunction perl mySub "an argument", "another" endfunction

to pass computed argument to your perl sub use the vim exec command
function! MyFunction exec "perl mySub " . aLocalVar . ", " b:aBufferLocalVar
endfunction

It may be very hard to debug your perl sub since the output of the perl
compiler is somehow lost in the middle of nowhere and the debugger is not
available.  When a compilation error occurs in your sub definition you'll get
an error message when you try to call it saying that the sub does not exists.
One thing which I have found very usefull is to write a fake VIM module with
stub methods which will allow you to use the command line perl interpretor
to at least compile your program.  You could make your stub smart enough to
fake a vim and use the debugger.  Here is a sample for such a fake module
defining just those method which I was using.

package VIM; use diagnostics; use strict; sub VIM::Eval {
	$_ = shift;

	print "Eval $_\n";

	{
		  return
		  '^(?!!)([^\t]*)\t[^\t]*\t(.*);"\t([^\t]*)\tline:(\d*).*$'
		  if (/g:TagsBase_pattern/); return $ARGV[0] if
		  (/b:fileName/); return '$3' if (/g:TagsBase_typePar/);
		  return '$1' if (/g:TagsBase_namePar/); return '$4' if
		  (/g:TagsBase_linePar/); return 'Ta&gs' if (/s:menu_name/);
		  return $ARGV[1] if (/g:TagsBase_groupByType/);
		die "unknown eval $_";
	}
} sub VIM::Msg {
	my $msg = shift; print "MSG $msg\n";
} sub VIM::DoCommand {
	my $package; my $filename; my $line;
    ($package, $filename, $line) = caller;

	my $command = shift; print "at $filename $line\n"; print "DoCommand
	$command\n";
} 1;

Then you can copy other your perl code in a separate file and add a use VIM;
at the top and your set to debug.

Good Vimming good perling.  Benoit PS: this tips are probably true for other
scripting languages

</pre></tip> </html> <Tip category="KVim"> <html><center>Add
your function heading with a keystroke</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=141">http://vim.sf.net/tip_view.php?tip_id=141</A><BR>

Below is a tip that the C/C++ Newbies may find interesting and handy to use.
The following code will add a function heading and position your cursor just
after Description so that one can document as one proceeds with code.

function FileHeading()
	let s:line=line(".")  call
	setline(s:line,"/***************************************************")
	call append(s:line,"* Description - ") call append(s:line+1,"*
	Author -      Mohit Kalra") call append(s:line+2,"* Date
	-	 ".strftime("%b %d %Y")) call append(s:line+3,"*
	*************************************************/") unlet s:line
endfunction

imap &lt;F4&gt;  &lt;esc&gt;mz:execute FileHeading()&lt;RET&gt;`zjA

Where &lt;esc&gt; stands for ^V+ESC and &lt;RET&gt; for ^V+ENTER

</pre></tip> </html> <Tip category="KVim"> <html><center>Automatic
function end commenting for C++ and Java</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=142">http://vim.sf.net/tip_view.php?tip_id=142</A><BR>

Some people have a habit of adding the function name as a comment to the
end of that function, if it is long, so that he/she knows which function the
'}' ends. Here's a way to automate the process.

Use the following abbreviation: iab }// } // END:
&lt;esc&gt;10h%$?\w\+\s*(&lt;cr&gt;"xy/\s*(&lt;cr&gt;/{&lt;cr&gt;:nohl&lt;cr&gt;%$"xpa

If you now end the function with '}//', the follwoing string will be
automatically generated: '} //END: functionname'

</pre></tip> </html> <Tip category="KVim"> <html><center>Use
of Vim folds for javadocs</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=143">http://vim.sf.net/tip_view.php?tip_id=143</A><BR>

Hi,

The fold-method marker can be effectively use to set the folds in your
Java source.  Define some marker and place it inside HTML comments &lt;!--
xx --&gt;.  This way, it does not affect the Javadocs generated without the
necessity of a seprate comment line.  e.g.

/**
 * &lt;!-- zz.FOLDSTART class AbcClass --&gt; * The class description.
 * ...	*/
public class AbcClass {

    /**
     * &lt;!-- method zz.FOLDSTART someMethod() --&gt; * Method description.
     */
    public void someMethod();

    ...

} /* zz.END: AbcClass */

/* Put this at the end of your file */ /* vim:fdm=marker
fmr=zz.FOLDSTART,zz.END fdl=2 fdc=2: */

Now, the files will be opened with the methods neatly folded.  You can use
"zR" to open all folds (or click on the "+" at the left column).

Sameer.

</pre></tip> </html> <Tip category="KVim"> <html><center>recording
keystrokes by "q" for repested jobs</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=144">http://vim.sf.net/tip_view.php?tip_id=144</A><BR>

The most useful feature that I find in VIM is the "recording" feature (:help
recording).  I have used this to automatically insert function headers,
re-indent lines, and convert some 34 source files into HTML.

This feature is most useful when you want to do some repeated jobs, which
you cant do easily using ".".  You can set about writing a function, define
a mapping, etc, but then these things might take time.	By recording, you
can try out and find the actual keystrokes that does the job.

To start recording, press "q" in normal mode followed by any of "0-9a-z".
This will start recording the keystrokes to the register you choose.  You can
also see the word "recording" in the status(?) line.  You can start the key
sequences that you want to record.  You can go to insert mode and type if
you want.

To stop recording, press "q" in the normal mode.

To playback your keystrokes, press "@" followed by the character you choose.
Pressing "@@" will repeat the same again.

Sameer.

</pre></tip> </html> <Tip category="KVim"> <html><center>Changing
DOS style end of line to UNIX, or vise-versa</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=145">http://vim.sf.net/tip_view.php?tip_id=145</A><BR>

Those of us doomed to work in both the Unix and Windows world have many times
encountered files that were create/editted on systems other that the one
we are on at the time of our edits.  We can easily correct the dreaded '^M'
at the end of our Unix lines, or make files have more than one line in DOS by:

To change from &lt;CR&gt;&lt;LF&gt; (DOS) to just &lt;LF&gt; (Unix): :set
fileformat=unix :w

Or to change back the other way: :set fileformat=dos :w

It also works for Apple land: :set fileformat=mac :w

And to tell the difference: set statusline=%&lt;%f%h%m%r%=%{&ff}\ %l,%c%V\ %P
					      ^^^^^  This shows what the
					      current file's format is.

Happy Vimming!

</pre></tip> </html> <Tip category="KVim"> <html><center>opening
multiple files from a single command-line</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=146">http://vim.sf.net/tip_view.php?tip_id=146</A><BR>

i use the :split command a lot -- both to open a second window containing
the currently edited file and to edit a new file altogether (with the :split
&lt;filename&gt; option).  however, i also like to be able to edit more than
one file and calling :sp multiple times is inconvenient.  so, i created the
following command, function and abbreviation:

function! Sp(...)
  if(a:0 == 0)
    sp
  else
    let i = a:0 while(i &gt; 0)
      execute 'let file = a:' . i execute 'sp ' . file

      let i = i - 1
    endwhile
  endif
endfunction com! -nargs=* -complete=file Sp call Sp(&lt;f-args&gt;) cab sp Sp

this retains the behaviour of :sp in that i can still type :sp (the
abbreviation takes care of that).  :Sp takes any number of files and opens
them all up, one after the other.

the things i have noticed are that this causes 'sp' to be expanded to 'Sp'
everywhere, even in search patterns.  also, prepending 'vert' doesn't work.
if there is interest, i'll do that.

</pre></tip> </html> <Tip category="KVim">
<html><center>How to write a plugin</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=147">http://vim.sf.net/tip_view.php?tip_id=147</A><BR>

This tip gives a skeleton for writing a plugin; Vim's help files have plenty
of details (:he plugin, :he write-plugin, :he plugin-details).

#
------------------------------------------------------------------------------
# Exit when your app has already been loaded (or "compatible" mode set)
if exists("loaded_YourAppName") || &cp
  finish
endif

# Public Interface: #  AppFunction: is a function you expect your users to
call #	PickAMap: some sequence of characters that will run your AppFunction #
Repeat these three lines as needed for multiple functions which will # be used
to provide an interface for the user if !hasmapto('&lt;Plug&gt;AppFunction')
  map &lt;unique&gt; &lt;Leader&gt;PickAMap &lt;Plug&gt;AppFunction
endif

# Global Maps: # map &lt;silent&gt; &lt;unique&gt;
&lt;script&gt; &lt;Plug&gt;AppFunction \ :set lz&lt;CR&gt;:call
&lt;SID&gt;AppFunc&lt;CR&gt;:set nolz&lt;CR&gt;

#
------------------------------------------------------------------------------

# AppFunction: this function is available vi the &lt;Plug&gt;/&lt;script&gt;
interface above fu! &lt;SID&gt;AppFunction() ..whatever..

# your script function can set up maps to internal functions
nmap &lt;silent&gt; &lt;left&gt; :set lz&lt;CR&gt;:silent! call
&lt;SID&gt;AppFunction2&lt;CR&gt;:set nolz&lt;CR&gt;

# your app can call functions in its own script and not worry about
name # clashes by preceding those function names with &lt;SID&gt; call
&lt;SID&gt;InternalAppFunction(...)

# or you could call it with call s:InternalAppFunction(...)  endf #
------------------------------------------------------------------------------

# InternalAppFunction: this function cannot be called from outside the #
script, and its name won't clash with whatever else the user has loaded
fu! &lt;SID&gt;InternalAppFunction(...)  ..whatever..  endf

#
------------------------------------------------------------------------------

Plugins are intended to be "drop into &lt;.vim/plugin&gt;" and work.
The problem that the &lt;Plug&gt;, &lt;SID&gt;, etc stuff is intended to
resolve: what to do about functions that have the same names in different
plugins, and what to do about maps that use the same sequence of characters?
The first problem is solved with &lt;SID&gt; (a script identifier number)
that vim assigns: program with it and your users will be happier when your
stuff works with all their other stuff.  The second problem: what to about
those maps is addressed with &lt;Plug&gt;, &lt;unique&gt;, etc.  Basically
the idea is: let the user know that there are clashes and don't overwrite
previously existing maps.  Use the user's preferred map-introducer sequence
(I like the backslash, but there are many keyboards which make producing
backslashes unpleasant, and those users usually prefer something else).

What I like to do is to have a pair of start/stop maps to reduce my impact
on the namespace.  When the starting map is used, it kicks off a starting
function that introduces all the maps needed.  When the stopping map is
used, it not only removes the maps the starter made but restores any maps
the user had had that would have clashed.  I also use the start/stop pair
of functions to set and restore options that cause my scripts difficulties.

Check out DrawIt.vim's SaveMap() function for a way to save user maps.
Restoring maps with it is easy:

if b:restoremap != ""
 exe b:restoremap unlet b:restoremap
endif

So you can see it sets up a string variable with all the maps that the user
had that would have clashed with my application.

One final thing: if your application needs to share information between
its various functions, see if you can use s:varname (a variable that only
your script's functions can access) or b:varname (a variable that anything
associated with the buffer your application is running with can access)
instead of using global variables.

Good luck and happy Vimming!

</pre></tip> </html> <Tip category="KVim"> <html><center>Make
great use of those homemade menus</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=148">http://vim.sf.net/tip_view.php?tip_id=148</A><BR>

Accidently discovered that using &lt;alt&gt;&lt;Menu Hotletter&gt;&lt;cr&gt;
(e.g &lt;alt&gt;b&lt;cr&gt; - for the buffer menu) causes the menu to break
out in a seperate window.  Selecting the menu with the mouse and then hitting
enter does not seem to do it.

I will have to learn to add hotletters to my menus now so that the mouse
can take a break.

I am a total newbie with vim, but constantly amazed....

</pre></tip> </html> <Tip category="KVim"> <html><center>Automatically
update your diff upon writing.</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=149">http://vim.sf.net/tip_view.php?tip_id=149</A><BR>

When trying to reconcile differences between files, and using the new 'diff'
functionality in Vim 6.0 you may want to automatically update the differences
as you are working along.  A convienent time is when you write out either of
the files you are diff'ing.  This autocmd will take care of doing that for you.

" If doing a diff.  Upon writing changes to file, automatically update the
  " differences au BufWritePost			 *		if &diff ==
  1 au BufWritePost		     *		    :diffupdate au BufWritePost
  *		 endif

</pre></tip> </html> <Tip category="KVim"> <html><center>Generating
a column of increasing numbers</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=150">http://vim.sf.net/tip_view.php?tip_id=150</A><BR>

You can use the "Visual Incrementing" script from

  <A
  HREF="http://www.erols.com/astronaut/vim/index.html#VimFuncs">http://www.erols.com/astronaut/vim/index.html#VimFuncs</A><BR>

to convert a block of numbers selected via ctrl-v (visual block) into a
column of increasing integers.	Select the column, press :I&lt;CR&gt;, and
the first line's number will be used as a starting value.  Subsequent lines's
numbers will be incremented by one.

If the ctrl-v block is "ragged right", which can happen when "$" is used to
select the right hand side, the block will have spaces appended as needed
to straighten it out.  If the strlen of the count exceeds the visual-block
allotment of spaces, then additional spaces will be inserted.

Example:  Put cursor on topmost zero, select column with ctrl-v, then :I

   vector[0]= 1;       vector[0]= 1; vector[0]= 1;	 vector[1]= 1;
   vector[0]= 1;  --&gt;  vector[2]= 1; vector[0]= 1;	    vector[3]= 1;
   vector[0]= 1;       vector[4]= 1;

This script works with both vim 5.7 (:so visincr.vim) or vim 6.0 (source it
as for vim 5.7 or drop it into the .vim/plugin directory).

</pre></tip> </html> <Tip category="KVim">
<html><center>an ascii table</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=151">http://vim.sf.net/tip_view.php?tip_id=151</A><BR>

There is an ascii table in the vim-help files, but it's hard to find.  Thus,
I shall give a pointer to it:

:help digraph-table

</pre></tip> </html> <Tip category="KVim"> <html><center>Dutch,
English, German, Hungarian, and Yiddish</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=152">http://vim.sf.net/tip_view.php?tip_id=152</A><BR>

Under <A
HREF="http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts">http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts</A><BR>
are links to spelling checkers for Dutch, English, German, Hungarian,
and Yiddish, all based on the original engspchk.vim.  The spelling checker
provides as-you-type spell checking; with vim6.0 it will avoid checking on
partially typed words.

Provided are several maps:

  \et : add  word under cursor into database for just this file \es : save
  word under cursor into database (permanently) \en : move cursor to the
  next	   spelling error \ep : move cursor to the previous spelling error
  \ea : look for alternative spellings of word under cursor

To use \ea you will need agrep:

  agrep source: <A
  HREF="ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z">ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z</A><BR>
  agrep Win exe: <A
  HREF="http://www.tgries.de/agrep">http://www.tgries.de/agrep</A><BR>

To use the spell checkers just source it in:

  ex.  so engspchk.vim

To read more about it see

  <A
  HREF="http://www.erols.com/astronaut/vim/index.html#Spelling">http://www.erols.com/astronaut/vim/index.html#Spelling</A><BR>

</pre></tip> </html> <Tip category="KVim"> <html><center>Making
Parenthesis And Brackets Handling Easier</center> <pre> <A
HREF="http://vim.sf.net/tip_view.php?tip_id=153">http://vim.sf.net/tip_view.php?tip_id=153</A><BR>

1) ++++++++++++++++++++++++++ "Automatic" bracket setting
+++++++++++++++++++++++++++++ 2) +++++++++++++ Further improvement of
parenthesis/bracket expanding +++++++++++++++++ 3) ++++++++++++++++++++++++++++
"Late" bracketing of text +++++++++++++++++++++++++++++ 4)
+++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++
++++

=======================================================================================

1) ++++++++++++++++++++++++++ "Automatic" bracket setting
+++++++++++++++++++++++++++++                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  