Vim Tips Wiki
m (Visual Studio PLUS vim Quickfix mode PLUS cygwin PLUS XFree86 moved to Quickfix and Visual Studio and cygwin: Page moved by JohnBot to improve title)
(Change to TipImported template + severe manual clean)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=345
 
|id=345
  +
|previous=344
|title=Visual Studio __PLUS__ vim Quickfix mode __PLUS__ cygwin __PLUS__ XFree86
 
  +
|next=346
|created=October 15, 2002 15:13
+
|created=October 15, 2002
 
|complexity=basic
 
|complexity=basic
 
|author=Brian K
 
|author=Brian K
 
|version=5.7
 
|version=5.7
 
|rating=2/2
 
|rating=2/2
 
}}
|text=
 
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 .
+
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:
+
Here's what to do:
   
1. install the following from cygwin:
+
1. Install the following from cygwin:
*perl
+
*perl
*cygutils
+
*cygutils
*bash
+
*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.
+
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..."
+
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'
+
4. Create the cygwin shell script defined below. Put the script in '/bin/dovcmake'
   
  +
<pre>
---begin cut-----
 
&#35;!/bin/bash
+
#!/bin/bash
&#35; This script takes output from
+
# This script takes output from
&#35; Visual Studio's nmake and reformats
+
# Visual Studio's nmake and reformats
&#35; it so that it can be parsed by
+
# it so that it can be parsed by
&#35; cygwin's vim default errorformat
+
# cygwin's vim default errorformat
&#35; setting
+
# setting
nmake /F $1 2&gt;&amp;1 | perl -n -e \
+
nmake /F $1 2&gt;&amp;1 | perl -n -e \
' chomp;
+
' chomp;
if(/^([a-z]:[^(]+)\((\d+)\)(.+)$/i) {
+
if(/^([a-z]:[^(]+)\((\d+)\)(.+)$/i) {
$f = $1; $l = $2; $m = $3;
+
$f = $1; $l = $2; $m = $3;
$f =~ s/\\/\//g;
+
$f =~ s/\\/\//g;
$cyp = `cygpath -au $f`; \
+
$cyp = `cygpath -au $f`; \
chomp $cyp;
+
chomp $cyp;
print qq{"$cyp",$l:$m\n};}
+
print qq{"$cyp",$l:$m\n};}
elsif(/error/i) {
+
elsif(/error/i) {
print qq{$_\n};
+
print qq{$_\n};
}'
+
}'
  +
</pre>
   
 
5. Add this map to your vimrc:
---end cut -----
 
 
set makeprg=/bin/dovcmake
 
map &lt;f7&gt; :make &lt;c-r&gt;%&lt;cr&gt;
   
 
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.
5. Add this map to your vimrc:
 
set makeprg=/bin/dovcmake
 
map &lt;f7&gt; :make &lt;c-r&gt;%&lt;cr&gt;
 
   
 
==Comments==
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.
 
 
You should look at the errorformat option ({{help|errorformat}}). This may solve your problem without Perl.
   
}}
 
 
== Comments ==
 
You should look at the errorformat variable. This may solve your problem without perl.
 
 
 
'''Anonymous'''
 
, October 16, 2002 1:09
 
 
----
 
----
I needed to use perl because I needed to convert windows paths from nmake's output to cygwin paths. Otherwise I would have used errorformat
+
I needed to use Perl because I needed to convert windows paths from nmake's output to cygwin paths. Otherwise I would have used errorformat
   
Brian K
 
, October 16, 2002 13:47
 
 
----
 
----
 
You could use Cygwin's cygpath to translate between Cygwin (posix) and windows paths instead of Perl.
 
You could use Cygwin's cygpath to translate between Cygwin (posix) and windows paths instead of Perl.
   
'''Anonymous'''
 
, December 2, 2002 6:54
 
 
----
 
----
I am using cygpath within the perl script to translate the paths, but the perl script does more that just translate paths. It also filters extraneous nmake output , such as the MS copyright info that nmake generates.
+
I am using cygpath within the Perl script to translate the paths, but the Perl script does more that just translate paths. It also filters extraneous nmake output , such as the MS copyright info that nmake generates.
   
Brian K
 
, December 3, 2002 11:21
 
 
----
 
----
Instead of using cygpath, you may want to look at whether cyg-wrapper.sh will help you. It handles a lot of the tricky path conversion issues between cygwin and Windows.
+
Instead of using cygpath, you may want to look at whether cyg-wrapper.sh will help you. It handles a lot of the tricky path conversion issues between cygwin and Windows.
--&gt; http://hermitte.free.fr/cygwin/&#35;Win32
+
http://hermitte.free.fr/cygwin/#Win32
   
'''Anonymous'''
 
, October 21, 2004 17:21
 
 
----
 
----
<!-- parsed by vimtips.py in 0.512289 seconds-->
 
 
 
 
[[Category:Cygwin]]
 
[[Category:Cygwin]]

Revision as of 12:25, 2 November 2007

Tip 345 Printable Monobook Previous Next

created October 15, 2002 · complexity basic · author Brian K · version 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'

#!/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};
    }'

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.

Comments

You should look at the errorformat option (:help errorformat). This may solve your problem without Perl.


I needed to use Perl because I needed to convert windows paths from nmake's output to cygwin paths. Otherwise I would have used errorformat


You could use Cygwin's cygpath to translate between Cygwin (posix) and windows paths instead of Perl.


I am using cygpath within the Perl script to translate the paths, but the Perl script does more that just translate paths. It also filters extraneous nmake output , such as the MS copyright info that nmake generates.


Instead of using cygpath, you may want to look at whether cyg-wrapper.sh will help you. It handles a lot of the tricky path conversion issues between cygwin and Windows. http://hermitte.free.fr/cygwin/#Win32