How to make notepad++ treat csproj files as XML automatically? - text-editor

I often use notepad++ for editing of the csproj files. And I always need to go to the Language menu and select XML in order to get syntax highlighting.
Is it possible to configure notepad++ to treat csproj files as XML automatically?

Open Settings -> Style Configurator, select "XML" in "Language" list, add "csproj" (without quotes) to "User ext" box.

Edit the file langs.xml in the notepad++ folder.
Change this
<Language name="xml" ext="xml xsml xsl xsd kml wsdl" commentLine="" commentStart="<!--" commentEnd="-->">
</Language>
by
<Language name="xml" ext="xml xsml xsl xsd kml wsdl csproj" commentLine="" commentStart="<!--" commentEnd="-->">
</Language>

Related

Sublime Text Syntax Highlight

Good morning. In Sublime Text 3 (Windows) I have installed the FountainHead extension. I would like to know where to find the syntax highlight file. Thank you.
Syntax highlighting is controlled by two files - the language parsing definition file, which ends in either .tmLanguage or .sublime-syntax, and the color scheme file, which ends in either .tmTheme or .sublime-color-scheme. .tmLanguage and .tmTheme files are in XML format, while the .sublime-* files are in JSON.
To view specific files in a package, open the Command Palette (CtrlShiftP) and hit v, which should bring up the View Package File option. Hit Enter, then type in FountainHead/ to see all the files in the FountainHead package. The language parsing definition file is in the main directory, and is called FountainHead.tmLanguage. The syntax highlighting .tmTheme files are located in the FountainHead/schemes subdirectory - there are 11 of them.

Can sublime 3.0 convert display from plain text to source color scheme automatically?

I'm little new to Sublime, wanted to know if there is a way to change display in sublime-3.0 from plain text to source colors automatically (i.e. Sublime should keep source colring from where code was copied and pasted like- HTML or XML or Java code) without I changing it manually.
Thanks in Advance!
Sublime Text already does this for some languages, like XML.
It works when you have a blank document that is set to Plain Text format (i.e. you open a new tab), and paste something in whose first line can be identified to be a specific language, using regular expressions.
For XML, it looks for an XML prolog or an XML element with a namespace. Regex
For HTML, it looks for a HTML doctype.
It currently doesn't support Java - I guess it's not easy to come up with a regex that would match only the first line of a Java file and not a C# file, for example. If you do have some ideas, you can use https://packagecontrol.io/packages/PackageResourceViewer to edit the relevant .sublime-syntax (YAML) file and add a first_line_match in.
You may also find the following packages helpful:
https://packagecontrol.io/packages/AutoSetSyntax
https://packagecontrol.io/packages/ApplySyntax
Extra note: these "first line matches" also apply when opening files that aren't automatically matched to a syntax by the file's name/extension.
There might be a better way, but I've done it with the Package control ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X). Search for Package Control: install Package, press Enter and then search whatever package you need.
After installing the SCSS package, I'd get the HTML colouring as well.

reading the version prefix from an external file instead of the .csproj file

At this time, my .csproj files contain the XPath /Project/PropertyGroup/VersionPrefix and that determines the version for the nuget packages.
However, I would prefer to read this version prefix from a shared file, as it will be common for 3 or 4 projects, each of whom have their own .csproj files.
In other words, instead of having
<VersionPrefix>2.0.0</VersionPrefix>
we would prefer to have something like
##include ../../version.xml
and this version.xml contains the line above which will be substituted.
I am sure there would be multiple ways to achieve this but cannot fathom exactly how. Help would be appreciated.
You can create a file named Directory.Build.props in the folder hierarchy above all your projects (e.g. next to the solution file) and put shared properties in there:
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
</PropertyGroup>
</Project>
MSBuild will automatically find and import this file. (you may need to re-open your editor / visual studio). See MSBuild's Customize your build documentation for more information.

This SVG is invalid. Validate it before opening

I just modified a svg file that came with my Wordpress Template but i come up to this: Error Line 787, Column 77: there is no attribute "sketch:type"
<g id="city-copy" transform="translate(1305.000000, 47.000000)" sketch:type="MSShapeGroup">
Open the svg in a text editor and remove the sketch:type="MSShapeGroup" attribute from the <g> element. An even better maneuver would be to optimize your svg with a tool like svgo.
Check the encoding value.
I changed the encoding="windows-1252" to encoding="utf-8" and worked for me.
This can be caused by a variety of things but I've been able to solve this by:
open the SVG in Inkscape
Go To File > Clean Up Document
Save the SVG (choose a unique file name so you do not lose your previous work).
guys! I saw this tip on another forum, and it worked. I managed to fix the corrupted file. What you have to do is:
Open the file in a text-editor (I used Dreawweaver)
Check the first line for entries like: xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;", and delete the '&' characters so it reads: xmlns:x="ns_extend;" xmlns:i="ns_ai;" xmlns:graph="ns_graphs;"
Save the file, and Illustrator will open it.
Good luck!
Thanks much for the how-to principle. In my situation, using that idea (of opening the corrupted SVG file with a text editor since Adobe Illustrator wouldn't open the file), I used a text editor (Smultron) to open both the corrupted SVG file and an openable SVG file. I compared the upper area of both files; saw that certain lines of code were missing from the corrupted SVG file; copied those few extra lines of code from the openable (working) SVG; and saved. AI could then open the formerly corrupted SVG file. I copied the layers I needed into a new AI file and abandoned the formerly corrupted SVG.
AI version CS7 is saving invalid SVG and SVGZ files. In my case, two namespaces were missing from the SVG file.
Use the Export to SVG instead. It save the SVG without the need for namespaces.
I had similar problems with svg files that I had saved in Adobe Illustrator. The easy fix for me was to open the files in Inkscape and save a copy, and these files are fine.
The original error message said "The SVG file is invalid. Validate it before opening." The ironic thing is that after saving a copy with a new name, the original files will now open in  Illustrator.
As a complete non-techy, I followed the advice above and opened my SVG in text editor. None of the problems above were in my file so I compared the file to a working SVG file, trialed a few things and discovered that
" 0 0 no-repeat
at the very end of the code outside of the tag was the culprit! Deleted this and voila! :-)
Wow, so many different answers! Might as well add my own... This is handled the error in Adobe Illustrator when opening a file downloaded from the internet, might work in other scenarios as well.
I opened the svg in a text editor and noticed that the XML prolog at the beginning did not match a different, working, file. Specifically the non-working one was version 1.1 and did not include the standalone="no" attribute. So the fixed prolog now reads:
<?xml version="1.0" encoding="UTF-8" standalone="no">
Worked for me!
After opening my svg in a code/text editor, in my case Visual Studio Code I noticed that mine had <DIV id="container"> and </DIV> surrounding the <svg..... > data.
Removing this div tag solved my issue.
I stumbled on another easy fix by luck: I was about to open an SVG in a text editor, when I noticed that OSX was defaulting SVGs to ImageOptim, an app I use for stripping metadata, etc. So I let that have the file, and a moment later I had a valid SVG file that took up 68% less space on disk.
I had a similar problem, which was not solved by any of the above mentioned solutions. In the end I solved it by unchecking the box 'Export RDF metadata' when creating the SVG file (in QGIS in this case).
Most likely something in the RDF metadata must have been unreadable for Illustrator, but I didn't manage to figure out what part exactly.

XSLT output BOM character visible in Excel

My Java EE web app uses XSLT transformation to produce CSV reports.
If I specify "UTF-16" as the encoding on the XSLT (which seems to be the only way to handle accented characters in the XML) then I get a byte-order-mark character at the start of the CSV output
From what I understand, this is correct behavior. The problem is that this BOM character is visible if the CSV is opened in Excel (appears as: þÿ), but not if I open it in a proper text editor ;)
How can I hide or omit this character so it isn't visible when the file is opened in Excel?
You forgot to specify which version of XSLT you are using.
If you are using XSLT 2.0, you can suppress the BOM using the xsl:output element. For example...
<xsl:output method="xml" byte-order-mark="no" encoding="UTF-16" indent="yes" omit-xml-declaration="yes" />
What if you are using XSLT 1.0?
Here are two options:
Upgrade to XSLT 2.0
Upgrade your Excel to 2007 (See here for why)
if you are writing a CSV file the method should probably not be "xml" as Sean B. Durkin suggests.
i recommend this configuration to make a CSV that will correctly open in Excel
<xsl:output method="text" byte-order-mark="yes" encoding="UTF-16LE" indent="no"/>
Other tips when using XSLT to generate a CSV:
You can use TAB characters even though CSV means "comma separated value"
I find the data i separate is often void of tabs but has the occasional comma.
and <xsl:text>
</xsl:text> is a way to add a line-break.
you probably want to escape linebreaks that occur in the values you use, like this:
<xsl:value-of select="replace($foo,'\n','\\n')"/>
and of course, you will quickly notice that if you open the file in Excel, it becomes read-only which is a bother when you try to generate the file again while it is still open. unlike most text editors which simply tell you the file has changed, and offer to reload it.
-
I realize this question is dated and answered already, but I hope this helps a future someone.

Resources