Keyboard Shortcut to Surround Selection with HTML Tag - eclipse

Desired Steps:
Highlight (select) HTML/text, e.g. really
Press keyboard shortcut
Highlighted text becomes <b>really</b>
How to?

In a Javadoc comment you can just select the text which you want to wrap in a <b> tag and press CTRL+Space. Select the <b> template, press Enter and the selected text gets surrounded as expected. There are pre-defined templates for <b>, <code>, <i> and <pre>. You can define your own templates here: Java -> Editor -> Templates.

You're looking for Quick Fix/Quick Assist: Ctrl/Cmd+1. Then start typing the tag name.

Related

Insert tab after some text instead of expanding when emmet expansion is on in VS Code

In VS code, when emmet.triggerExpansionOnTab is on I can write something like "div", then press [tab] to generate a HTML tag like this:
<div></div>
Which is very useful, but it also happens when I press [tab] anywhere, If I write "something" and press [tab] I get this:
<something></something>
I would like to be able to create tags and ALSO be able to insert regular tabs (\t) after any word.
Is there a hotkey or something to insert a regular tab after some text without creating a tag?

In VSCode, how can I select current element and it"s surroundings like in WebStorm?

In WebStorm you can select an element and it's surrounding when you do Alt + Arrow Up.
How can you achieve that in VSCode ?
You can try with VSCode buit in Emmet: Balance (outward) command: Ctrl+Shift+A
If the shortcut does not work, follow these steps:
Press Ctrl+Shift+P to open the Command Palette
Type Emmet
Select Emmet: Balance (outward)
This will select the tag where you have your cursor currently in, and all its contents (I understand that by its surroundings you mean the tag contents and the tag itself).
If the tag has as a content a combination of text and tags and your cursor is in the text, the command will select all the content. A new hit of the command will grow the selection to include the tag itself.

How to surround some html code in Eclipse with new tag (shortcut)?

I want to surround some HTML code with <div> - how to do it in Eclipse with some shortcuts or macros. I do not want to repeat surrounding manually.
<p>some text</p>
I want to surround with <div> and achieve
<div><p>some text</p></div>
Follow below mentioned steps :
Select the text that you want to surround with tag.
Go to 'Edit > Quick Fix' or press 'Ctrl + 1'.
Double click "Surround with new element"

NetBeans commenting

I'm using the popular IDE NetBeans and I have problems commenting code on the same line. For example, let's say we have the following line:
<h1> Some text </h1> comment for h1
I would like to comment the part "comment for h1" through a key combination or some other means but without having to type manually and without transferring the comment string to the next line. I usually use ctrl+/ but this key combination comments the whole line, which is not what I want.
Why not Select & Replace all such occurences.
You can use Ctrl + Shift + H and enter the text which you want to replace.
Add the text (say comment for h1) to be commented in the field Containing Text, and replace that text with //comment for h1 in the Replace With field.
Then it will show you all the matches which you want to comment. You can select the desired places where you want to place comment before the text.
Finally, click on Replace ? Matches button. Voila, that's it...
You can always create your own keyboard shortcut, see how in this link.
Then you can customize your keyboard to replace your highlighted text with the same text with /* */ , // , <!-- --> or any others before/surrounding the text.
Example:
<h1> Some text </h1> comment for h1
Highlight the text you need to comment (comment for h1).
Use your customixed shortcut and:
<h1> Some text </h1> /*comment for h1*/
I haven't tested this, please tell me your feedback ;)
I've decided to do this by recording 2 macros and assigning shortcuts to them:
ctrl + shift + A for the html comment <!-- -->
ctrl + shift + \ for the php comment /* */.
Both macros position the mouse cursor in the middle of the comment section so it is convenient to enter a comment. This doesn't work with an existing comment.
select the texe and use Ctrl+Shift+C

Sublime Text 2 - HTML autocomplete

In ST2 when you type div.foo and then press tab it goes to <div class="foo"></div>
Is there any setting to do autocompletion like that?
<div class="foo">
// 4spaces here.
</div>
Thank you.
UPDATED
Didn't find a special setting but found where to change snippet if someone intested.
In Sublime Text 2/Packages/HTML/html_completions.py just change
snippet = "<{0} class=\"{1}\">$1$0".format(tag, arg)
to
snippet = "<{0} class=\"{1}\">\n\t$1\n$0".format(tag, arg)
Solved.
You must be using emmet.... stock sublime text 2 does not auto complete class attribute from typing element.class that is emmet's doing. I use it... I love that emmet magic.
Similarly you could type element>element to make the second one nest on the first one. or element#id to add an id instead of a class...
Here is an entire cheat sheet for emmet for more completions using emmet plugin on ST2.
Make sure your page is on HTML. You can do this with CTRL+SHIFT+P. Then type 'set html'.
Then you can type div.class_name followed by TAB.