ovid-vim - Ovid's Vim Setup
git clone email@example.com:Ovid/ovid-vim.git ln -s ovid-vim/.vimrc ~/.vimrc ln -s ovid-vim/.vim ~/.vim # copy bin/ files to your path
People keep asking me for my vim setup, so I've cleaned it up a bit and am posting it here. It's sort of old-school because I never switch to a package manager. I also don't claim that it's a brilliant example of vim usage. It just reflects how I used vim. Because I'm almost always hacking on Perl, it's very Perl-specific in many ways.
I never documented this code properly because no one else was every using it. I also DO NOT CLAIM THIS IS SUITABLE FOR ANYONE ELSE. You've been warned. It's only here because people ask for it. Also, note that some things I've told people about are not here because I need to clean up my code even more. This also means that some things may not work as expected because I did so much cleanup.
FILES TO READ
You probably would be most interested in:
I've set my leader to the comma. The comma is actually a command in vim:
, Repeat latest f, t, F or T in opposite direction [count] times.
I don't use that command, so it works for me. Your mileage may vary. You can
change your leader by resetting it at the top of the
When in Perl, typing
K when on a module name or keyword will attempt to
perldoc with the appropriate documentation.
Common commands I use:
|,w||Jump to the next window|
|,h||Turn off highlighting|
|,pp||Toggle paste mode|
|,ls||List current directory contents|
|,la||List current directory contents, including hidden files|
|tab||(visual mode) indent selected lines|
|shift tab||(visual mode) unindent selected lines|
My embarrassing git integration is a legacy from years ago when I used CVS, then switched to Subversion, and now use git. I should learn to use fugitive.
|,ca||git annotate current file|
|,cl||git log current file|
|,cr||git review current file|
|,cd||git commit current file (you cannot commit without a review)|
|,c1||find first commit in repo with the current|
The following are in the git section because they use git internally.
|,g||Prompt for a search term and search your
When you edit yoru
.vimrc file, we automatically pick up the changes with:
au! BufWritePost .vimrc source %
The following non-core modules are required by some helper scripts:
The following core modules are required by some helper scripts:
These are often miserable hacks, but they work for me. They assume that when
you are in a Perl project, you stay in the home directory of said project (in
other words, you don't
cd t or
Also, often depends on your
@INC being set up correctly.
|,e||(visual mode) Extract subroutine|
|,pv||When your cursor is on a module, print the module version|
|,pt||(visual mode) Run
|,d||Run the Perl debugger on the current buffer|
|,rr||Rebuild my current project (requires a bash script that needs to be updated)|
|,s||Print subroutines found in current buffer. Nasty hack.|
|,S||List unused subs in current buffer (hack)|
|,gg||GoGo to module's tests, or test's module (see )|
|,gm||Jump to the module name under the cursor|
|,gp||Jump to pod for the module name under the cursor|
|,gs||Jumps to the sub definition (if found) of the sub name found under the cursor|
|,r||Run the code in the current buffer|
|,r||(visual mode) run selected lines and insert output after|
- Runs a modified
perl -con the current buffer. Uses
Vi::QuickFix. See also this blog post.
- If in a module, jump to its tests ("GoGo"). If in the tests, jump to the
module. Requires some hacking on the
bin/get_correspondingfile. I need to update that to allow per-project configuration.
If you're in a
*.t file, we assume you're running tests.
|,r||Run the current test file in verbose mode|
|,t||Run the current test file in verbose mode|
|,T||Run the current test file and output the results into a new buffer|
|,fp||Turns all comments into explain() statements. Test must use Test::Most|
|,tb||Run all tests open in current buffers|