Vim Tips Wiki
No edit summary
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 16: Line 16:
 
</pre>
 
</pre>
   
Can someone assist here with why the file isn't getting created? I think it might be because the path isn't valid so the script might be failing to create the file in the first place and thus fails to read it. Thanks, -Frank
+
Can someone assist here with why the file isn't getting created? I think it might be because the path isn't valid so the script might be failing to create the file in the first place and thus fails to read it. Thanks, -Frank
:No idea, but in a new command prompt window enter <tt>set t</tt> to list all environment variables beginning with 't' (or 'T') and check your TEMP and TMP settings. They should be the same, and should refer to an existing directory where you have write permission (probably Full Control). Can you create the file mentioned above (after changing the double backslashes to single), i.e. '''not''' using Vim. [[User:JohnBeckett|JohnBeckett]] 00:36, May 26, 2010 (UTC)
+
:No idea, but in a new command prompt window enter <code>set t</code> to list all environment variables beginning with 't' (or 'T') and check your TEMP and TMP settings. They should be the same, and should refer to an existing directory where you have write permission (probably Full Control). Can you create the file mentioned above (after changing the double backslashes to single), i.e. '''not''' using Vim. [[User:JohnBeckett|JohnBeckett]] 00:36, May 26, 2010 (UTC)
 
----
 
----
Here is the output from <tt>set t</tt>:
+
Here is the output from <code>set t</code>:
<tt>TMP=C:\DOCUME~1\feaves\LOCALS~1\Temp</tt>
+
<code>TMP=C:\DOCUME~1\feaves\LOCALS~1\Temp</code>
This is the strange thing, the 'f' in feaves is changed to 'x0c'. Any idea what could be causing this? <small>--Preceding [[Vim Tips Wiki:Quick reference|unsigned]] comment added by [[User:anon|anon]] 17:33, June 15, 2010</small>
+
This is the strange thing, the 'f' in feaves is changed to 'x0c'. Any idea what could be causing this? <small>--Preceding [[Vim Tips Wiki:Quick reference|unsigned]] comment added by [[User:anon|anon]] 17:33, June 15, 2010</small>
   
 
----
 
----
 
This is a bug in the script because it passes a string to Python where the string contains backslashes as directory delimiters, but those backslashes can have a special meaning.
 
This is a bug in the script because it passes a string to Python where the string contains backslashes as directory delimiters, but those backslashes can have a special meaning.
   
To illustrate the problem, in a command prompt window, run <tt>python</tt> and enter the following after the <tt>>>></tt> prompt (and press Ctrl-Z Enter to exit):
+
To illustrate the problem, in a command prompt window, run <code>python</code> and enter the following after the <code>>>></code> prompt (and press Ctrl-Z Enter to exit):
 
<pre>
 
<pre>
 
>>> a='C:\Temp\fab'
 
>>> a='C:\Temp\fab'
Line 37: Line 37:
 
Python has left the '\T' unchanged because it has no special meaning, but '\f' is translated to a byte with hex value 0c because \f is formfeed which is 12 = 0x0c in ASCII.
 
Python has left the '\T' unchanged because it has no special meaning, but '\f' is translated to a byte with hex value 0c because \f is formfeed which is 12 = 0x0c in ASCII.
   
A possible workaround would be to edit the <tt>visual_studio.vim</tt> script. Search for <tt>$TEMP</tt> in that file, and insert the following line before the blank line preceding the first occurrence:
+
A possible workaround would be to edit the <code>visual_studio.vim</code> script. Search for <code>$TEMP</code> in that file, and insert the following line before the blank line preceding the first occurrence:
 
<pre>
 
<pre>
 
let mytemp = substitute($TEMP, '\\', '/', 'g')
 
let mytemp = substitute($TEMP, '\\', '/', 'g')
 
</pre>
 
</pre>
   
Then change all the subsequent <tt>$TEMP</tt> occurrences to <tt>mytemp</tt> which is the value of $TEMP with each backslash replaced with a forward slash. Both Python and Vim work with a forward slash used as a directory delimiter. I have not tested this. [[User:JohnBeckett|JohnBeckett]] 08:11, June 16, 2010 (UTC)
+
Then change all the subsequent <code>$TEMP</code> occurrences to <code>mytemp</code> which is the value of $TEMP with each backslash replaced with a forward slash. Both Python and Vim work with a forward slash used as a directory delimiter. I have not tested this. [[User:JohnBeckett|JohnBeckett]] 08:11, June 16, 2010 (UTC)
   
 
----
 
----
Line 76: Line 76:
   
 
==errorformat==
 
==errorformat==
 
 
The output window in vs2008 had a '>1' prefix in each line.
 
The output window in vs2008 had a '>1' prefix in each line.
   

Latest revision as of 09:54, 14 July 2012

Use this page to discuss script 864 visual_studio: Vim and Microsoft Visual Studio .NET integration

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Comments[]

I love this script but when I do a build (\vb) I get the following errors in Vim:

Error detected while processing function DTEBuildSolution..<SNR>18_DTEExec:
line   13:
Trackback (most recent call last):
  File "<string>", line 1, in ?
  File "C:\Program Files\Vim\vimfiles\visual_studio\visual_studio.py", line 80, in dte_build_solution
    dte_output (vs_pid, fn_quickfix, 'Output')
  File "C:\Program Files\Vim\vimfiles\visual_studio\visual_studio.py", line 191, in dte_output
    fp_output = file (fn_output, 'w')
IOError: [Errno 2] No such file or directory: 'C:\\DOCUME~1\x0ceaves\\LOCALS~1\\Temp\\vs_output.txt'

Can someone assist here with why the file isn't getting created? I think it might be because the path isn't valid so the script might be failing to create the file in the first place and thus fails to read it. Thanks, -Frank

No idea, but in a new command prompt window enter set t to list all environment variables beginning with 't' (or 'T') and check your TEMP and TMP settings. They should be the same, and should refer to an existing directory where you have write permission (probably Full Control). Can you create the file mentioned above (after changing the double backslashes to single), i.e. not using Vim. JohnBeckett 00:36, May 26, 2010 (UTC)

Here is the output from set t: TMP=C:\DOCUME~1\feaves\LOCALS~1\Temp This is the strange thing, the 'f' in feaves is changed to 'x0c'. Any idea what could be causing this? --Preceding unsigned comment added by anon 17:33, June 15, 2010


This is a bug in the script because it passes a string to Python where the string contains backslashes as directory delimiters, but those backslashes can have a special meaning.

To illustrate the problem, in a command prompt window, run python and enter the following after the >>> prompt (and press Ctrl-Z Enter to exit):

>>> a='C:\Temp\fab'
>>> a
'C:\\Temp\x0cab'
>>> len(a)
10

Python has left the '\T' unchanged because it has no special meaning, but '\f' is translated to a byte with hex value 0c because \f is formfeed which is 12 = 0x0c in ASCII.

A possible workaround would be to edit the visual_studio.vim script. Search for $TEMP in that file, and insert the following line before the blank line preceding the first occurrence:

let mytemp = substitute($TEMP, '\\', '/', 'g')

Then change all the subsequent $TEMP occurrences to mytemp which is the value of $TEMP with each backslash replaced with a forward slash. Both Python and Vim work with a forward slash used as a directory delimiter. I have not tested this. JohnBeckett 08:11, June 16, 2010 (UTC)


I think the bug can be fixed in the function of DTEExec in visual_studio.vim. Although I don't fully read and understand the source code of this plugin, I have tried the following changes, which fix the problem on my computer.

At line 167, change the code from

       let arglist += ["\"" . pyarg . "\""]

to the following:

       let arglist += ["\"" . substitute(pyarg, '\\', '\\\\', 'g') . "\""]

I am not heavily use this plugin yet, I don't know if this changes cause other problems, but you can have a try. Hope this helps. (Gilbert Fine)

Q2[]

I have another problem when trying to build a solution here:

Error detected while processing function DTEBuildSolution..<SNR>45_DTEExec:
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "C:\Program Files\Vim\vimfiles\plugin\visual_studio.py", line 62, in dte_build_solution
    if _dte_has_csharp_projects(dte):
  File "C:\Program Files\Vim\vimfiles\plugin\visual_studio.py", line 397, in _dte_has_csharp_projects
    if dte.CSharpProjects.Count:
  File "C:\Program Files\Python.2.4.4\Lib\site-packages\win32com\client\dynamic.py", line 512, in __getattr__
    raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: <unknown>.CSharpProjects

This can be a silly question, but I have no knowledge about Python. After commenting out the code about csharp, I can build the solution now. A greate VIM script!

errorformat[]

The output window in vs2008 had a '>1' prefix in each line.

http://vim.1045645.n5.nabble.com/Need-help-with-errorformat-td1191004.html

let g:visual_studio_quickfix_errorformat='%.%#%*[0-9>]\ %#%f(%l)\ :\ %m'