Often when I do a file comparison, I want to edit my local file before committing to TFS (it's efficient). I'm able to do this with kdiff3's 3-way merge. But how do I accomplish this during comparison? I know that it's possible with BeyondCompare3, as I used to do it in the past.
These are my Tools --> Options --> Visual Studio Team Foundation Server --> Configure User Tools --> Compare Operation:
%1 -fname %6 %2 -fname %7
Was looking for answer myself, found this question, so updating with my findings.
Appears to me that edit of A or B file isn't supported out of the box in kdiff3, but you can keep an eye on this feature request opened in 2004 :)
There are workarounds though (found in comments here)
Option 1 is to use these parameters for Compare: %1 --fname %6 %2 --fname %7 -o %2, it will output to B (-o %2 part).
Option 2 is to use parameters you're using but then you'll need to click "Merge current file" in Menu and after that click "Select Line(s) from B" in the output window context menu, after that you'll be able to edit.
Related
Seems a good place as any to ask
So I want to assign a file name being processed by a batch file to:
LASTFOLDERIN%1PATHNAME-FOLDERNAME.rar using the %1 Windows sends me from the context menu.
So far I'm able to ALMOST make it, I get so far as:
WinRAR.exe a -r -ep1 -u -m0 -y "C:\Sorting\ %~p1-%~n1.rar" "%~1\*.*"
Which returns:
\FULL(DIR1\DIR2\DIR3)PATH\-FOLDERNAME.RAR
But the problem is I get the FULL path (multiple directories), not just the very last one, also, I get the \ that breaks the whole thing.
Question is, is there a way to extract just the last folder in the path variable %~1 that I get from the windows context menu argument?
Or if not, can I somehow replace the \ with - so I can rename the files manually later? to get something like this: -DIR1-DIR2-DIR3-FOLDERNAME.RAR
Any help would be greatly appreciated, I'm stuck here.
PS I'm sending %V to the batch file, since %1 did all kinds of weird things.
In your comment you asked: "Now if anyone knows how to get the last 2 directory variables instead of just the last one... it would be awesome haha."
My answer was: "Simple: after set "PATHNAME=%1" use set "last1=%PATHNAME:\=" & set "last2=!last1!" & set "last1=%" & set "lastTwo=!last2!\!last1!" The result is in %lastTwo%"
I think this is fairly simple code (just two lines). Anyway, here it is such a code, with the mod required to also get the third-to-last directory:
#echo off
setlocal EnableDelayedExpansion
set "PATHNAME=%1"
set "last1=%PATHNAME:\=" & set "last3=!last2!" & set "last2=!last1!" & set "last1=%"
echo Full path name: %PATHNAME%
echo Last dir only: %last1%
echo From 2nd to last: %last2%\%last1%
echo From 3rd to last: %last3%\%last2%\%last1%
Output example:
Full path name: DIR1\DIR2\DIR3\DIR4\DIR5
Last dir only: DIR5
From 2nd to last: DIR4\DIR5
From 3rd to last: DIR3\DIR4\DIR5
ok I've found something that is definitely not elegant but does the job, if anyone can improve by all means, this is the best I could do and it gets the job done, here's the code for the batch files:
(Thanks to Squashman for the working code for spaces and recursive dirs)
For last dir only
for %%G in ("%~dp1\.") do set "PATHNAME=%%~nxG"
"WinRAR.exe" a -r -ep1 -u -m0 -y "C:\[Sorting]\%PATHNAME%-%~n1.rar" "%~1\*.*"
Returns: LASTPATHDIR-SELECTEDDIR.RAR file in a specific folder, id wish I could add this to the drag and drop handlers but alas I cant only DLLS can be there, so this is the next best thing, I just change the batch file whenever I need it stored somewhere else, you can call a path variable instead on the batch file and just update it whenever you need it changed if you like, so you dont have to change all the batch files every time.
For 2nd to last + last dir:
for %%G in ("%~dp1\.") do set "PATHLAST=%%~nxG"
for %%G in ("%~dp1\..") do set "PATH2NDLAST=%%~nxG"
set PATHNAME=%PATH2NDLAST%-%PATHLAST%
ECHO Processing %PATHNAME%-%~n1.rar"
"WinRAR.exe" a -r -ep1 -u -m0 -y "C:\[Sorting]\%PATHNAME%-%~n1.rar" "%~1\*.*"
for third to last + second to last + last:
for %%G in ("%~dp1\.") do set "PATHLAST=%%~nxG"
for %%G in ("%~dp1\..") do set "PATH2NDLAST=%%~nxG"
for %%G in ("%~dp1\..\..") do set "PATH3RDLAST=%%~nxG"
set PATHNAME=%PATH3RDLAST%-%PATH2NDLAST%-%PATHLAST%
ECHO Processing %PATHNAME%-%~n1.rar"
"WinRAR.exe" a -r -ep1 -u -m0 -y "C:\[Sorting]\%PATHNAME%-%~n1.rar" "%~1\*.*"
make sure to make 3 different batch files and call them accordingly.
If anyone cares here's the accompanying code for the right click context menu.
(just make sure the archiver batch file and the winrar path is added to the path environment variable)
Windows Registry Editor Version 5.00
;--============== CR =============--
[HKEY_CLASSES_ROOT\*\shell\CRARFILE1]
#="Add to SORTING (Last)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\*\shell\CRARFILE1\command]
#="\"(ArchiverLast).bat\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER1]
#="Add to SORTING (Last)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER1\command]
#="\"(ArchiverLast).bat\" \"%V\""
[HKEY_CLASSES_ROOT\*\shell\CRARFILE2]
#="Add to SORTING (2ndLast)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\*\shell\CRARFILE2\command]
#="\"(Archiver2ndLast).bat\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER2]
#="Add to SORTING (2ndLast)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER2\command]
#="\"(Archiver2ndLast).bat\" \"%V\""
[HKEY_CLASSES_ROOT\*\shell\CRARFILE3]
#="Add to SORTING (3rdLast)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\*\shell\CRARFILE3\command]
#="\"(Archiver3rdLast).bat\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER3]
#="Add to SORTING (3rdLast)"
"Icon"="WinRAR.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\CRARFOLDER3\command]
#="\"(Archiver3rdLast).bat\" \"%V\""
Delete any entries you don't need (like if you only need the last one)
If you want to do that quickly here's a batch file to do it, it will append this path to your path variable.
#ECHO OFF
setx Path "%PATH%;C:\Program Files\WinRAR\" /m
Hope this helps others, its saved me so much work so far
I was wondering if there was a simpler way to change the case of just the highlighted colored programming text (For In While Do Set etc) in one go by color using notepad++ or sublime text. So for example change the case of all the blue text in a batch file test.bat:
SETLOCAL DisableDelayedExpansion
FOR /F "delims=" %%A IN ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c
ECHO(0x09"') DO SET "TAB=%%A"
ECHO This is a %TAB%
The syntax would be changed to title case like:
Setlocal DisableDelayedExpansion
For /F "delims=" %%A In ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c
Echo(0x09"') Do Set "TAB=%%A"
Echo This is a %TAB%
I currently do this by Right Clicking and then selecting Plugin Commands> Copy Text with Syntax Highlighting from the context menu, copying this text to Microsoft word and saving it as an html file, opening the html file in notepad++ for editing and then pasting text-transform: uppercase; under the line color:blue; and then opening it again in word (not in edit mode) and finally copying it to notepad++ but would like to know if there is a simpler way without looking up each individual word but instead just batch formatting words of a similar color.
Sublime has an internal command called title_case to perform this manipulation, which is available from the menu as Edit > Convert Case > Title Case or from the command palette as Convert Case: Title Case.
So if all of the keywords in the document were selected, you could use that command to perform the operation. You would probably have to do it in batches (pun mildly intended), such as putting the cursor in SETLOCAL and repeatedly pressing Ctrl+D to select all of the instances, then cycle back and do the next keyword.
To automate the process a little better, a simple plugin can be created that selects all of the keywords and runs the command, so that you can perform the bulk of the operation in one simple step.
An example of that is the following, which you can use by selecting Tools > Developer > New Plugin... from the menu, replacing the stub code with the code below, and then saving in the location Sublime will default to as something like dos_batch_case_fix.py or something similar (only the location and extension matter):
import sublime
import sublime_plugin
# A list of extra words to change the title case for that aren't considered
# keywords by the dos batchfile syntax.
_extra_words = ["do", "in"]
class BatchTitleCaseCommand(sublime_plugin.TextCommand):
"""
For a dos batch file, convert the case of all keywords and all found
instances of the words in _extra_words to title case.
"""
def run(self, edit):
# Save the current selection, then clear it
saved_sel = list(self.view.sel())
self.view.sel().clear()
# Find everything that the syntax thinks is a keyword and add it to
# the selection
for region in self.view.find_by_selector("keyword"):
self.view.sel().add(region)
# Convert the list of extra words to a regular expression and add all
# whole word matches to the selection.
regex = r"\b({0})\b".format("|".join(_extra_words))
for region in self.view.find_all(regex, sublime.IGNORECASE):
self.view.sel().add(region)
# Convert the selection to title case.
self.view.run_command("title_case")
# Restore the selection to what it was on entry.
self.view.sel().clear()
for region in saved_sel:
self.view.sel().add(region)
def is_enabled(self):
return self.view.match_selector(0, "source.dosbatch")
This implements a new command named batch_title_case that is only active in batch files. It saves the current selection, then selects all of the keywords (as determined by the syntax currently in use), runs the command to change the case, then puts the original selection back. You can bind this command to a key the same as you would for any other internal command.
Since this uses the syntax of the current file to detect what a keyword is, it doesn't catch things like IN and DO because (at least currently) the Sublime syntax for Batch files doesn't think those are keywords.
For that reason, this also shows how you could handle those sorts of words. The code here does a case insensitive whole word search for a list of words (represented in _extra_words) and selects those as well as the selected text.
This is semi-dangerous in that unlike the keyword search by syntax scope, the regex search will find those words anywhere, including inside of strings where they might not represent keywords but just regular words instead.
As such it's probably a good idea to use this on a copy of the file (or be able to undo) and verify that it hasn't done something that you didn't otherwise expect.
I would imagine that a visual inspection would be much less effort than the solution you're currently using.
Potential changes
If desired, the plugin above could be modified to remove the portions that save and restore the selection along with executing the title_case command; in that case the command would only alter the selection in the file to the words that it thinks that it needs to title case and allow yo to take the action manually.
Note that if you work with a really large file that contains a lot of keywords, having that many simultaneous selections may slow things down a bit.
Invoking the command
The plugin above creates a command named batch_title_case. There are a variety of ways to execute the command, depending on how you want to proceed. Where the User package is mentioned below, you can use the Preferences > Browse Packages command from the menu to locate it. The User package is the location where the plugin above is stored, since Sublime defaults to that location when you use Developer > New Plugin.
Via a key binding
Using Preferences > Key Bindings, you can add a custom binding to the right hand side of the window that references the command:
{
"keys": ["ctrl+alt+s"],
"command": "batch_title_case",
},
Via the Command Palette
The command can be added to the command palette by adding a file of type sublime-commands to your User package with the following contents (e.g. MyCustomCommands.sublime-commands). The caption will specify how the command appears:
[
{ "command": "batch_title_case", "caption": "Command Caption Here" },
]
Note: As written above, the command is only enabled for a batch file, and the Command Palette only shows you available commands, so in non-batch files the command will not appear in the command palette.
Via the context menu
The command can be added to the right click context menu by creating a file named Context.sublime-menu in your User package; if such a file already exists, add only the { ... } line to the appropriate place in the existing file. The caption will specify how the command appears:
[
{ "command": "batch_title_case", "caption": "Command Caption Here" },
]
Note: As written above, the command is only enabled for a batch file, so in non-batch files the command in the menu will appear grayed out. To hide the context menu item in files that it doesn't apply to, add the following lines to the plugin code above under is_enabled():
def is_visible(self):
return self.is_enabled()
I'm trying to figure out how to get Visual Studio to read a set of include files from a text file.
For example, I would like to create a text file called IncludePaths.txt that contains a list of include paths such as "/I ../../header"
I would then tell Visual Studio reference this file.
I believe you could do this by adding #IncludePaths.txt to the Additional Include Directory, but I cannot get this to work. I have seen this done in projects I have worked on in the past but I can't find any documentation or figure out the trick.
After a little more research and talking to a couple of other developers, I figured out the "trick"
1) Create a file called IncludePaths.txt next to my project file.
2) Add your include paths to this file...
/I "..\..\..\..\open\common\include"
/I "..\..\..\common\include"
/I "..\..\"
3) Go to Properties -> C++ -> Command Line
4) Under "Additional Options" add #IncludePaths.txt
Alternatively, you can use custom properties to get this to work too.
I am currently trying to print a HTML file using mshtml.dll. Looking up in the registry I found for html-files, the following print-to entry:
"%systemroot%\system32\rundll32.exe"
"%systemroot%\system32\mshtml.dll",PrintHTML "%1" "%2" "%3" "%4"
Unexpectedly there are some parameters to pass to mshtml.dll, what are the parameters of mshtml.dll (numbered %1, %2, %3, %4 in this registry information)?
You found this in the printto verb of the htmlfile progid. Which runs when you drag an HTML file from Explorer and drop it on a printer shortcut. The printto verb has these arguments:
%1: the path to the HTML file
%2: the printer name
%3: the printer driver name (optional)
%4: the printer port name (optional)
Taking a dependency on an undocumented function is unwise, you can't rely on this still working in the next Windows version. Using WebBrowser.Print() is the documented way. IWebBrowser2::ExecWB() in native code.
Neither the printer's name is mandatory, in fact in the "print" verb of the htmlfile progid only one parameter is specified for the same command.
By the way: I tried to replace %2 with the printer's name (with and without quotes) but it didn't do anything different, that is, the print dialog is still there.
Tried on Windows 10 and Windows 7.
We use Vs2010 with TFS 2010
The settings for source control [merge || compare ] are:
Everything is working fine for cs + aspx + html extensions.
But there is a problem with css extension ( and we can't figure why) :
For all other files it DOES show the merge button (when there are conflicts) :
But for css extension files there is no Merge button :
Why is that ? and how can I change it ? (already looked at settings , but couldn't find any related section).
Additional unrelated info :
We use Beyond compare as our compare tool
The exact settings for the compare operation :
Command: C:\Program Files\Beyond Compare 3\BComp.exe
Arguments %1 %2 /title1=%6 /title2=%7 /solo
The exact settings for the Merge operation :
Command: C:\Program Files\Beyond Compare 3\BComp.exe
Arguments %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
Connect to your TFS server and go to your Team Explorer panel. Select Settings->Source Control
Check if the .css file extension is registered. For me it shows up under the Common Web Files category but I am on 2012