Is there a way to use $ in a tab trigger for html scoped sublime snippets? - sublimetext2

For some reason when I try to use the dollar sign for anything in my sublime text snippets in html, like if I create a sublime text snippet with the $ used as the tabtrigger and try to use it by typing $ and pressing tab, what I get is this:
<1></1>
And not the code I put into the snippet. However, if I use the dollar sign as a tab trigger for any other scoped object it works fine. Does anybody have any idea what conflict is causing this?

Related

How can i format visual studio code to add an indented space between curly brackets in CSS when i hit enter?

When I open the curly brackets in CSS and hit enter, it just jumps to the next line like this:
body {
}
It doesn't add a new line with an indentation like it used to, I tried looking through the setting and trying everything but couldn't get a result.
I want it to look like this when I press Enter:
body {
}
What you need is a VSCode plugin called "Prettier".
It can be downloaded in the "Extensions" section of VSCode,
or downloaded from this link: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
You can try the following:
Check if you have set your default formatter to prettier
You can check the box to Format On Save or ;
Autosave: There are are currently 4 options available -:
a) off
b) afterDelay
c) onFocusChange
d) onWindowChange
To anyone who is facing this problem in VSCode. This feature is not related to any extension, not Prettier or any other extension. What you have to do to fix this bug is:
Go to the settings
Search for Folding Strategy and choose the Auto option
Then enable Folding
It adds that indentation in both HTML and CSS

How to create typing shortcuts in Sublime Text 2?

I am back to using Sublime Text 2 after some time and I noticed that I had made shortcuts to type certain expressions faster. For example, in Java, the common System.out.println() is immediately suggested as the first choice after typing pr in the editor since pr was the trigger that I chose for System.out.println(). After typing pr, I press enter and System.out.println() is written on the editor.
I don't remember how I did this or what is the name of the procedure to do this (hence, it is hard to search it online). All I remember was editing some text file in Sublime and adding the shortcut.
Creating snippets or "shortcuts" is easy in Sublime Text.
For your example, you would simply have to do the following:
Go to Tools > New Snippet...
Inside the CDATA brackets, put the code snippet you want to be generated
Uncomment the tabTrigger tag and put "pr" inside it. This is the shortcut you want to use to generate the snippet.
Uncomment the scope tag and put source.java inside it. This will make the this snippet only show up when you're working with Java files.
Save the file to your Packages > User folder and name the file whatever you want. Make sure you end it with a sublime-snippet extension.
In this example, I saved it as println.sublime-snippet. This is what it ended up looking like in the end:
<snippet>
<content><![CDATA[
System.out.println();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pr</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.java</scope>
</snippet>
You can learn more about customizing your snippets with things like tab stops here.
Take a look in your Java snippets:
Windows:
%APPDATA%/Sublime Text 2/Packages/Java/println.sublime-snippet
OSX:
~/Library/Application Support/Sublime Text 2/Packages/Java/println.sublime-snippet
Linux:
~/.Sublime Text 2/Packages/Java/println.sublime-snippet
And edit the tabTrigger tag as follows (should originally contain pl):
<snippet>
<content><![CDATA[System.out.println($1);$0]]></content>
<tabTrigger>pr</tabTrigger> <!-- Update this to pr-->
<scope>source.java</scope>
<description>println</description> <!-- I changed this to System.out.println -->
</snippet>
Now, typing pr in a Java file will bring up the autocomplete list. The first entry will read 'pr', and to the right of it, whatever you have between the <description> tags.
Pressing Tab or Return after typing "pr" will fill in System.out.println() and leave your cursor between the brackets.
You may also need to edit the "private" snippet, located in the same directory, to change it's trigger to something other than "pr" (pri, etc).

Format Code In MonoDevelop

I am using MonoDevelop on Mac to write MonoTouch apps. Automatica code indenting/formatting works great while I am typing.
The problem is that when I copy and paste code snippets, in many cases I lose the formatting and lines are combined together, indenting is lost, and it is a huge pain to implement the tabs, spacing, and line breaks manually. Is there anyway I can use a command in monoDevelop to automatically indent and apply the formatting to existing code.
I thought maybe Edit|Format|Format Document/Selection would work, but these commands don't have any affect on the code at all.
Any help?
To format the entire document in one keystroke: control-I
To format a selection: Edit->Format->Format Selection
To customize the formatting: MonoDevelop->Preferences->Source Code->Code Formatting
You actually need to select all your text, and then go to Edit->Format->Format Document. It doesn't seem to work otherwise.
For me on macOS, the shortcut for "auto-format" is CTRL + i.
You can change the shortcut if you want. To change it, go to Preferences -> Key Bindings, then type "format" in the search box and edit the "Format Document" shortcut/key binding.

Surround selection with html tag

Is there any eclipse shortcut/trick/plugin/whatever that will allow me to select a section of text and surround it with an arbitrary html/xml tag when using the html editor.
Something like this textmate video
EDIT: not sure If my Eclipse setup is the same as yours, but...
I have the HTML Editor installed, and if I switch to the Java perspective, I can use Edit -> Quick Fix and then choose Surround with new element to get exactly the effect in your video. (On a Mac, the shortcut for this is ⌘1).
Hope this is helpful.
In the C++ editor, you can try Source -> Surround With... -> Configure Templates to add the tag you want.
The following works and allows for entering random/arbitrary tags:
Select the desired text that you want wrap.
Go to 'Edit > Quick Fix' or press 'Ctrl + 1'.
In the new menu that appears select 'Surround with new element'
However there is an annoyance, please upvote Bug 494169

How to use hotkey in notepad++ webedit plugin?

How to use hotkey in notepad++ webedit plugin?
what are the keyboard shortcuts to press to insert html tags??
Install the "webedit" plugin. Which will allow you to add custom shortcuts.
(Plugins > plugin manager).
After the program restarts, go to plugins > webedit > edit config. And either change an existing one or add a new one, (example &A= | ). You can remove the shortcut icons if they annoy you.
Then you go to, settings, shortcut mapper. Right now, ctl+enter is set to word completion I believe. Change that to something else (on main menu). Then go to the plugin commands tab and find your command and set it to ctl+enter. Then restart, and it should work.
http://www.graphicdesignforum.com/forum/showthread.php?t=52719
All keyboard shortcuts can be assigned/modified using the standard Shortcut Mapper. For more information see the WebEdit.txt help file.
That's what it says in the plugin description, at least.
Setting>Keyboard Shorcut>Plugins commands
then go to
- WebEdit - A
- WebEdit - Div Class
- WebEdit [...]
and select shortcut
I see that someone sort of answered it but I have a few things to add.
When you install WebEdit, go to the config as stated.
Go down to the [Tags] section.
Underneath all the comments, add the shortcut you want.
Here is the syntax:
<Tag>=<Replacement>
For tag, put what you want to replace. For example 'h1' (dont use the carrots).
put the = sign.
Then for replacement, put what you want "h1" to be replaced with.
Here is an example of my h1 hotkey:
h1=<h1>|</h1>
What the pipe character does is tell npp where to put your cursor after the replacement.
So this is how you use it now:
type h1, then press 'Alt+Enter'(by default, you can change this too), then BAM, your 'h1' will be replaced with:
<h1></h1> and your cursor will be sitting between the tags.
You could also do h1=<h1>|\n</h1> which would print the same thing but with a line break.
You can do some pretty awesome stuff with it. Saved me SO much time once I got used to it. I never type without it anymore lol.
Here is what my personal setup looks like under the [Tags] section (and I commented everything below starting with the m=module because it was messing with my 'p' tag and I didn't care anyways.
begin=<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n\n|</body>\n</html>
h1=<h1>|</h1>
h2=<h2>|</h2>
h3=<h3>|</h3>
h4=<h4>|</h4>
h5=<h5>|</h5>
h6=<h6>|</h6>
html=<html>\n|\n</html>
script=<script type="text/javascript">\n\t\n</script>
link=<link rel="stylesheet" type="text/css" href="|">
a=
div=<div>
divclass=<div class="|">
divid=<div id="|">
divend=</div>
p=<p>|</p>
ul=<ul>\n\t|\n</ul>
li=<li>|</li>
header=<header>\n\t|\n</header>
nav=<nav>\n\t|\n</nav>
section=<section>\n\t|\n</section>
article=<article>\n\t|\n</article>
aside=<aside>\n\t|\n</aside>
footer=<footer>\n\t|\n</footer>
Remember one thing; after you edit the WebEdit, you have to restart NPP before the new tag will work.
I know this is a bit old, but you can use the Emmet plugin to speedup your HTML and CSS typing. you can customize your snippets to make any text.
It cames whith dozens of snippets already, you just have to type it and then hit Ctrl+Alt+Enter.
You can find the file to edit in this path:
C:\Program Files (x86)\Notepad++\plugins\EmmetNPP\emmet\snippets.json
It's easy to spot what you have to do.
On the plug-ins menu you will find all options that this plugin offers.
Experiment it like typing html:5 and then hit Ctrl+Alt+Enter.
Or even this ul>li*4>a[href=page.php?id=$]{page $}.
You will be amezed.
Check this online documentation for keyboard & mouse shortcuts