Tip #345: Visual Studio + vim Quickfix mode + cygwin + XFree86
tip karma |
Rating 1/1, Viewed by 980
|
created: |
|
October 15, 2002 15:13 |
|
complexity: |
|
basic |
author: |
|
Brian K |
|
as of Vim: |
|
5.7 |
I run gvim inside a cygwin XFree86 session running WindowMaker. Because I'm inside cygwin-XFree86, I can't use the useful VisVim plugin to step through Visual Studio compiler errors. To work around this limitation, I wrote a Bash/Perl script that munges nmake output into something that has cygwin compliant path and is parseable by the default quickfix errorformat setting .
Here's what to do:
1. install the following from cygwin:
- perl
- cygutils
- bash
2. Set up Visual Studio to support command line compiles. Basically this involves adding paths to the PATH, INCLUDE, and LIB environment variables. See vcvars32.bat in the Visual Studio VC98/bin directory for guidelines.
3. Export a makefile for your dsp project file via the Visual Studio "Project|Export Makefile..."
4. Create the cygwin shell script defined below. Put the script in '/bin/dovcmake'
---begin cut-----
#!/bin/bash
# This script takes output from
# Visual Studio's nmake and reformats
# it so that it can be parsed by
# cygwin's vim default errorformat
# setting
nmake /F $1 2>&1 | perl -n -e \
' chomp;
if(/^([a-z]:[^(]+)\((\d+)\)(.+)$/i) {
$f = $1; $l = $2; $m = $3;
$f =~ s/\\/\//g;
$cyp = `cygpath -au $f`; \
chomp $cyp;
print qq{"$cyp",$l:$m\n};}
elsif(/error/i) {
print qq{$_\n};
}'
---end cut -----
5. Add this map to your vimrc:
set makeprg=/bin/dovcmake
map <f7> :make <c-r>%<cr>
6. Fire up cygwin vim and open the makefile from step 3. If you hit F7, you'll automatically start a Visual Studio build and you'll be able to step through compiler errors via the :cp and :cn commands.
<<Cut / Copy / Delete / Paste Lines without knowing the number of lines |
Wrap text in HTML/XML tags after prompting for the tag name >>
Additional Notes
|