MacVim, remapping Alt-key as Ctrl-key - macvim

I am a MacVim user, and I would like to know if it's possible to make the Alt-Option key behave as a Ctrl key.
Thanks for your time.

I couldn't find a way of doing it inside MacVim, but KeyRemap4Macbook did the trick. It is a FANTASTIC piece of software, the documentation is just excellent, I recommend it to everybody in difficult mapping situations.
It allows you to customize mappings for each app, in an xml file that you can open from inside the app. It's absolutely poka-yoke.
This is what I wrote in private.xml, for my situation:
<appdef>
<appname>MacVim</appname>
<equal>org.vim.MacVim</equal>
</appdef>
<item>
<name>Change Right Option key to Control</name>
<identifier>private.remap_rightOption_to_control</identifier>
<only>MacVim</only>
<autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::CONTROL_R</autogen>
</item>
Problem solved!

Related

What is "overlay" in sublime text editor?

What is the "overlay" in ST and how can it be used? (please indicate default key bindings)
It's just a generic interface element which pops up a list of options and a field for searching them. Examples of overlays include the command palette (Ctrl+Shift+P) and Goto Anything (Ctrl+P).
Do you talking about command which by default binded to "ctrl+;"?
As far as i know it works like find(ctrl+f), but overlay can search for one word only.
For example we have this file:
Someone correct my english pls
If we will use find command we could look for more than one word like "my english".
But if we gonna use overlay we could to search for "my" or "english" only.
We can't search with overlay for "my engligh" cuz here is more than one word.
Sublime Text can read settings from multiple configuration files.
The default order is described here.
Packages/Default/Preferences.sublime-settings
Packages/Default/Preferences (<platform>).sublime-settings
Packages/User/Preferences.sublime-settings
<Project Settings>
Packages/<syntax>/<syntax>.sublime-settings
Packages/User/<syntax>.sublime-settings
<Buffer Specific Settings>
The latter configuration files override ("overlay") the former, allowing you to have more specific settings for certain programming language, project, etc.

Use method name for SublimeText 2 autocomplete as well as tab trigger

The default SublimeText 2 snippets, located in the Packages directory and then under, say, Ruby are useful but only if you happen to know the tab trigger. For example the file ~/Library/Application Support/Sublime Text 2/Packages/Ruby/alias_method-..-(am).sublime-snippet contains:
<snippet>
<content><![CDATA[alias_method :${1:new_name}, :${0:old_name}]]></content>
<tabTrigger>am</tabTrigger>
<scope>source.ruby</scope>
<description>alias_method ..</description>
</snippet>
So we can access this trigger by hitting am then tab.
My question is, if this snippet chucks in alias_method :${1:new_name}, :${0:old_name} isn't there a way that I can use this snippet without knowing its am trigger, just by starting to type alias_m... for example?
Umm, no, not that I can find. I just opened up a blank Ruby file, hit a, and autocomplete popped up with all sorts of options, including the snippet you mentioned. However, if I then typed an l (starting to spell out alias...), the option for the am snippet disappeared. So, it looks like autocomplete is not searching the <description> field, only the <tabTrigger> field. There aren't any options in Preferences -> Settings - Default that would seem to address this situation.
So, unfortunately it would seem the solution is one of two things - either edit all your commonly-used snippets to have tabTriggers that make more sense to you, or put together a snippet cheat sheet. It looks like at least one other person was thinking the same thing, as I found this collection without too much searching.
Good luck!

WP8 Voice Command Definition file multiple languages

When building a VCD you define the languages like so:
<CommandSet xml:lang="en-US">
...
</CommandSet>
<CommandSet xml:lang="ja-JP">
...
</CommandSet>
My question is, if I want multiple languages to use the same CommandSet (such as en-US and en-GB) is that possible without copy/paste?
EDIT: The option listed in this answer doesn't work. It seems the best way to avoid VCD multi-langage copy-paste is to use T4 templates to generate VCDs are compile time.
Yep, that's actually pretty simple. As long as you don't have CommandSets overlapping you can create a CommandSet for the entire language without mentioning a specific region. Remember, xml:lang is a generic XML attribute and you can use that to your advantage.
In the code snippet below we'll specify an en (English) voice command set without the need to mention specific regions.
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0">
<CommandSet xml:lang="en">
<Example> English example </Example>
<!-- ... -->
</CommandSet>
<CommandSet xml:lang="es-ES">
<Example> Non-english example </Example>
<!-- ... -->
</CommandSet>
</VoiceCommands>
When we run this code snippet we can see the different Example text showing up in different emulators:
One limitation here is that you can't have a xml:lang="en" CommandSet at the same time as region specific english CommandSets (e.g. xml:lang="en-us"). For the overwhelming majority of apps, that's fine. If you're however embedding a region specific PhraseList you'll have to use alternative strategies (e.g. list of movies only available in specific regions due to copyright restrictions) . One option I've seen before is a T4 template generating a VCD file instead of having a repetitive copy-paste VCD file.
This is no longer possible. With WP8.1 you MUST supply the xml:lang.

Run a regular expression into a new file (or another existing file)

I would like to take some stuff from file A and reformat it to stick into file B using regular expressions. I am kind of new to vim so this may be a dumb question but I could not find the solution to this anywhere. I guess I am searching for the wrong phrases. Anyway, here are the details of what I want to do. I have a static html page that I would like to have an RSS feed for. Luckily, this page is mostly links to various news items, so creating the RSS will be pretty easy.
I have the regular expression ready:
:%s/^<a href="\(.\{-}\)".title="\(.\{-}\)">\(.\{-}\)<\/a>/<title>\3<\/title>\r<link>\1<\/link>\r<description>\2<\/description>
My problem is I do not want to make the changes in the html file that I am searching. I want the changes to occur in another file, new or existing. How do I make this happen? Or is this method completely off.
Oh and by the way, this expression takes something like this in the html file:
Title of Link
and turns it into this in the xml file:
<title>Title of Link</title>
<link>http://linktosomesite.com</link>
<description>Description of link</description>
Bonus: It would be really nice if I can place this within another file, say starting at line 5.
PS: I know this is a vim and regex question but posting it in html and rss because I noticed people have static html to rss questions there.
Why not just copy your file and then use sed/replace on the copied file?
It sounds like you want to write a transform. There are many transform tools. You certainly could do it with sed & awk for example. But I think the easiest way would be xslt. (you could use xsltproc or saxon...)
Here's an example template:
<xsl:template match="a">
<title><xsl:value-of select="text()"/></title>
<link><xsl:value-of select="#href"/></link>
<description><xsl:value-of select="#title"/></description>
</xsl:template>
It finds each a element, and outputs the results, with the text() node and attributes filled in.
Just run your substitution and save as another file:
$ vim file.html
:%s/^<a href="\(.\{-}\)".title="\(.\{-}\)">\(.\{-}\)<\/a>/<title>\3<\/title>\r<link>\1<\/link>\r<description>\2<\/description>
:w file.rss
:q
That's how I would in any editor, by the way.

How to view xsd:documentation that is in HTML markup?

I am generating WSDL/XSD for SOAP services from a UML model using IBM Rational Software Architect (RSA). RSA allows you to document the classes and attributes in the model using rich-formatting.
For example, I have the following documentation on a Trailer class:
A wheeled Vehicle that is designed for towing by another
Vehicle. Known subtypes include:
Caravan
BoxTrailer
BoatTrailer
When the UML model is transformed to WSDL/XSD (using the out-of-the-box UML to WSDL transform), the formatting is preserved as HTML markup inside the xsd:documentation element:
<xsd:complexType name="Trailer">
<xsd:annotation>
<xsd:documentation><p>
A&nbsp;wheeled <strong>Vehicle</strong> that is designed for&nbsp;towing by another <strong>Vehicle.</strong> Known
subtypes include:&nbsp;
</p>
<ul>
<li>
<strong>Caravan</strong>
</li>
<li>
<strong>BoxTrailer</strong>
</li>
<li>
<strong>BoatTrailer</strong>
</li>
</ul></xsd:documentation>
</xsd:annotation>
</xsd:complexType>
Unfortunately, this is really hard to read and I've been searching (with no luck) for a program that can view WSDL/XSD with documentation in HTML markup.
XmlSpy 2008 can't do it, RSA can't do it (which is a bit surprising, as it generated the XSD in the first place), neither can any web browser I've tried.
I did write a JET template that extracted the documentation from the model and outputted to HTML, and I could probably write some XSLT to do something similar from the XSD, but I was hoping there's a program out there (ideally free) that could view the documentation as HTML.
Essentially, I'd like to be able to tell the consumers of our web service that they can view the WSDL in X program if they want to read the documentation - does anybody know the best solution to this?
Edit:
Thanks for the suggestions, but I think I have a solution! I didn't realise that RSA can export a WSDL to HTML (right-click on WSDL, export, HTML). The generated HTML has a graphical view of each schema element, the documentation for each element, as well as the original source, and everything is hyperlinked together.
Most importantly, the documentation is richly-formatted again! One small caveat is that the ;nbsp's appear in the HTML output. This seems to be because the ampersand is escaped in the HTML:
&nbsp;
Instead it should be
I will update my model-to-model transform to ensure that the ;nbsp's are replaced with real spaces (I don't believe I'll need non-breaking spaces in the documentation), so the generated WSDL/XSD won't ever have them.
I highly doubt if the standard xml/xsd editors can interpret the html tags and generate appropriate documentation. Oxygen XML Editor does a decent job of understanding and converting the XML entities (liket < etc) but HTML tags and entities are left as is. Below is the screen shot in design view.
The type of <xs:documentation> is <xs:any> so you should actually be able to include your documentation without escaping the markup, provided that it is a well formed XHTML fragment instead of HTML. I guess some XML Schema tools would be capable to interpret the embedded XHTML and show it as formatted text.
Do note that if the markup is not escaped it absolutely must be a well formatted XML fragment or the documentation element will cause your schema to be malformed. This applies also to HTML entities! If the documentation contains an (unescaped) entity reference (other than the 5 pre-defined XML entities), then your schema either must contain an external DTD reference or have an embedded DTD that defines what is the replacement text of that entity. In your case the documentation contains an entity reference. Probably easiest will be to replace such entities with the corresponding Unicode character/text or with character references (use   for )
If you have a chance, try to include the documentation without escaping the markup and make sure that it will be well formed. Otherwise you probably need to process the documentation twice: 1) parse the schema and extract documentation 2) parse the documentation text again (possibly as HTML, not XML).
I've tried this with the latest build of QTAssistant and it shows like this in the Schema Help Panel only; I've put a feature request for the grid view, as well as the documentation generator to work the same. Is this what you're expecting?
The help panel shows the annotation of the schema object that is selected in the Graph/Diagram view. To display the help panel press F1.
This issue is fixed in RSA 8.0.4 - which now supports exporting to WSDL/XSD with plain text (as well as an option to sort the schema by type, then name alphabetically!).
To view the the documentation in a WSDL/XSD generated from a UML model in prior versions of RSA, the easiest solution is to export the WSDL/XSD as HTML using RSA. You can do this by right-clicking on the WSDL/XSD, selecting export, then selecting HTML.
The generated HTML has a graphical view of each schema element, the documentation for each element, as well as the original source, and everything is hyperlinked together.
Most importantly, the documentation (that's virtually unreadable in the WSDL/XSD) is richly-formatted again! One small caveat is that the ;nbsp's that RSA's documentation editor inserts also appear in the HTML output. This seems to be because the ampersand is not only escaped in the WSDL/XSD (which is good), but also in the HTML (bad!):
&nbsp;
Instead it should be
A simple workaround to this is to replace all &nbsp;'s in the WSDL/XSD with real spaces before generating the HTML.