Tech Trip Reports Still Here External ArtKomiChen.com |
|
VIM (VI iMproved) Tweaks This is not meant to be a VIM tutorial or quick start guide. This is just a place where I document things that I found hard to find from VIM's documentation and/or through the website. Mostly these are tips for hard core VIM geeks. Currently I'm using version 5.6. That may not reflect the latest version. But most of these things should work in 5.x.
My VIMRC file Here's my _vimrc/.vimrc file. I do not keep a separate _gvimrc file and in general use this file for both UNIX and Windows NT VIM initialization - hence the weird backupdir line. Notes on
Options:
set viminfo='100,\"50,n~/.viminfo It's easier to view the help on your options here (:help viminfo). The viminfo file maintains your histories (search, commandline, registers etc...) between file edits. It'll be like you never left VIM! :) set statusline=%1*%F%*\
%y\ %2*%r%m%*\ %=%l/%L\ (%p%%) My status line has filepath, ReadOnly Status (RO), Modified Status(+), Current Line / Total Lines, and percentage of file traversed. If you use my highlightings, the RO and + should appear in red. :set laststatus=2 ensures that all my windows will have statuslines. if &term ==
"xterm-color" Take note that the ^H there is really a CTRL-H, so make sure you prepend a CTRL_V during your insertion of it in your vimrc file (hit CTRL-V CTRL-H so a literal control character is inserted). Depending on your terminal, this might fix your backspace problem. Do a help :term to see some specific terminal issues - this one can drive you batty! :map <F2>
:!p4 edit %<CR> :e! <CR> These options are only useful if you are a Perl developer or use Perforce for source control. You can map them to whatever key you want. I've chosen <F7> here to stay consistent with the "compile" key in Windows/Dos compilers. Based on these I'm sure you can come up with the right command to map things for CVS as well. If you are setting them explicitly in command mode during a VI session, after you type :map you can type the key you want to map it to. If the keyname doesn't appear, your terminal might not support that keystroke. Do a :set termcap to see what VIM thinks your terminal settings are. These are some initiations that are not explicitly in my _vimrc/.vimrc startup file but that I cinlude from time to time. Put it in a file wherever you want and when you want to use just :source your_filename from the VIM command line. function InitWin32Gui() :autocmd GUIEnter * call InitWin32Gui() This actually is in my NT _vimrc file, my only exception to the "one vimrc" file rule. And the only reason why is because I haven't figured out how to only call this in Windows. If someone knows, please let me know! :) The :winpos 600 0 call explicitly sets the VIM windows position and the :set lines=76 explicitly sets the window size. map <C-F3> :%s/<FORM .*>\|<INPUT .*>\|<SELECT .*>\|<OPTION .*>/&/gi Occasionally I'll map this key. Basically if I'm trying to put together a script for an HTML page, this is useful when I have the HTML page in another window. Since I have :set hlsearch (highlight searches) it makes it easy to pick out various FORM tags. This command does a global search on the pattern and replaces the pattern with itself (&). I use the :%s instead of / because / doesn't implement the trailing /i option to ignore case. Hopefully they'll implement that soon. Perl Tagging This information was not the easiest to dig up. But if you want more information do a :help perl_info and some information should be there with additional links on where you can dig up more. In general there are two things to do:
Limitations of Perl tagging (at least with the script here): Tagging uses the first match found in the tagging file. As a result only unique function names can be found (usually not a problem) but with the advent of Perl OO common functions like "new" do not work well with tagging. Also explicit object referencing via :: also does not work. However most function names are unique so this often is not a problem. It certainly makes life easier when going through a lot of perl files! Getting around faster:
Quick Windowing Commands:
Other Useful Commands:
Tips:
Looking for a Visual/Graphical Diff? Look no further than the VIM package itself. I don't see this reference anywhere in the formal documentation but if you go poking around in the shared VIM directories you'll find a program called gvimdiff. On my system, I find it here: /usr/local/share/vim/vim55/tools/gvimdiff This is a csh script that uses diff and gvim to produce a great visual diff. It works in console mode as well if you can't run gvim, just symbolic link vimdiff to gvimdiff and it'll figure things out.
Last Updated: March 28, 2000 Maintainer: Timothy Chen <babyduck@massconfusion.com> All Content is Copyrighted 1998-2003 by Timothy Chen All Rights Reserved unless clearly stated otherwise. |