Is there a Surround With for aptana studio plugin? - html

Is there some way to get "surround with" in the Aptana perspective in Eclipse like you have in the Java perspective. I would love to be able to surround text with html tags like eg: <div></div> with a keyboard shortcut. Is there some way of doing that with the snippets rubles?
Thanks,

You can do this with AutoHotKey, which has the added benefit of being available across all apps. I have a script which launches a 'surround' menu when I select some text and press CTRL+SHIFT+C
To use it, install AutoHotKey, and create a new .txt file with the following code, and replace the extension with .ahk
http://pastebin.com/48ipiXsG
At the top of the file you'll find a number of groups of items, in the following format
<h1>~<h1>##</h1>
the ~ character divides the name of the function and the function content. The bit before ~ is what appears on your menu, and after the ~ is the code. ## represents where your selected text will go. So if you select the text 'AutoHotKey' and press CTRL+SHIFT+C, and then select <h1> from the menu, it'll replace the with <h1>AutoHotKey</h1>
There are several menus in the script, set up to launch based on what app you press CTRL+SHIFT+C in. For example, I get different shortcuts if I'm in Visual Studio than if I'm in SQL Server. You can modify these easily enough, but the generic menu should work fine for you. Feel free to chop and change but you have to leave GENERIC at the top of the script.
PS: I use this script everyday, and there is one small bug. The script saves whatever you have in the clipboard in a variable, and then writes it back to the clipboard when it's done. Sometimes, instead of surrounding text it replaces it with whatever you had in the clipboard. This is easily undone with CTRL-Z and usually works the second time you try it. I've never been able to figure out what causes this, maybe some autohotkey heads can help out?
PPS : This script is based on some other scripts from the AHK forums, including this one
http://www.autohotkey.com/docs/scripts/FavoriteFolders.htm
So you may find comments that don't make sense. I've seen a few references to the middle click, as the script above uses the middle mouse button instead of CTRL+SHIFT+C.

Related

Create a keyboard shortcut to Google Lens

Recently there is this "Search images with Google Lens" in the contextual menu (triggered from the right click) in Chrome browser, which is super useful.
For those who doesn't know yet, if you click on that item you can define a screenshot area and then Google Lens page opens with the image you just framed. And then it lets you search for "things" inside this image.
What I try to do is to find a way to assign a hotkey to trigger that menu item without being forced to use the mouse (e.g. ctrl + alt + s). The reason I want to do that is because I overuse this functionality and I am in a keyboard-over-mouse increase productivity mind of set.
My first thinking was to make a page script that would trigger that contextual menu and click the item but as far as I know there is nothing in the JavaScript API with that much power
(There is this " JavaScript - simulate click on contextmenu " but they are not talking about the native Chrome contextual menu I believe.)
Another option would be to use some key automation program like AutoHotKey in windows but there is one problem, the contextual menu is not always located in the same position relative to the mouse (e.g. if the menu is triggered at the bottom of the page it will appear above the mouse pointer).
Other than that I don't really see another solution.
I am digging for some idea and maybe you could help me if you are interested in the same outcome.
EDIT: For whoever may be interested
I made this python script
https://github.com/vdegenne/lens-clicker
It works on my computer, I can now get the result I want. But I keep this question opened for more ideas, seeking a better solution.
(You can also contribute to the project on the GitHub page).
I use Vimium, an extension to allow vim-like keybindings for browser navigation.
You can add search engines, for example Google Lens as so:
i https://lens.google.com/uploadbyurl?url=%S Google Lens
So once I have the URL of the image in the clipboard, I type o, i, Space, Ctrl + v, Enter
I'm working on finding a way of getting the URL of the image, but am not sure Vimium supports this. If not, using the URL template (above) to search Google Lens is still a much more robust way than by automating clicks on a menu, so hopefully that's helpful.

How to not close the editor window when closing the last tab in VS Code

If there's only one tab on an editor in VS Code, the default behavior is to close the editor right then and there.
Personally, and I think many others agree with me, this behavior is very annoying since the programmer would rather preserve the layout he or she created for the project's workspace.
How do I change this behavior?
I've found discussions on this topic, but all of the solutions do not seem to be the ideal one of simply leaving the editor open but empty. Most of them simply delete the related shortcuts, which seems to me like cutting your arm off just because you broke it.
Anyway, here are some useful links:
Superuser StackExchange: How to prevent VScode from closing editor when pressing ctrl+w with no tabs open?
Issue #54492: Remove CtrlCmd+W keybinding to close window when no editors are opened
The behavior of the shortcut ctrl+w is as-designed closing the application
Actually, VSCode 1.57 (May 2021) will change that:
Removed Cmd+W / Ctrl+W as keybinding to close window when no editor is opened
We have gotten feedback that users are frustrated when the window suddenly closes after having closed the last editor via rapid Cmd+W / Ctrl+W usages.
A quick poll in the team also revealed that many had the keybinding for closing a window unassigned, so we went ahead and removed Cmd+W / Ctrl+W as keybinding to close window when no editor is opened.
You can easily bring the keybinding back by configuring it as follows:
{
"key": "cmd+w", // use "ctrl+w" on windows
"command": "workbench.action.closeWindow",
"when": "!editorIsOpen && !multipleEditorGroups"
}
Note: on all platforms there is a dedicated assigned keybinding to close the window:
macOS: Cmd+Shift+W
Linux: Alt+F4
Windows: Alt+F4
If what you are looking for is to preserve empty groups as well as empty editor windows, there is an option in the preferences that gets you almost all of the way:
"workbench.editor.closeEmptyGroups": false
This has the effect that an editor group will stay open even if the last tab within it is closed.
but all of the solutions do not seem to be the ideal one of simply leaving the editor open but empty
Reddit has an answer providing you the ideal solution of leaving the editor open, but empty: close all tabs but leave editors open.
In brief, they suggest to use in rapid succession the "close all editors" and the "three column editor layout".
They suggest to create a macro like:
"macros": {
"closeAllTabs": [
"workbench.action.closeAllEditors",
"workbench.action.editorLayoutThreeColumns"
]
}
then bind it to a key combination. macrosRe is advised.
The behavior of the shortcut ctrl+w is as-designed closing the application, see #49023. It is advisable to remove the shortcut and cut the arm, since it is design to work like that. However, for version 1.43.1 a new comment was posted this year on a thread you linked. You might want to have a look at it as well.

Move cursor across html tags in text editor

How can I move the cursor across HTML tags in a text editor like Sublime Text or anything else instead of pressing ctrl+arrow (not a direct move) keys so many times?
Is there any shortcut available?, if not, how can I create one for Sublime Text editor?
Here is how I want to move the cursor.
<html>
<p>
"a"
</p>
<div>
"b"
</div>
</html>
I want move the cursor from position a to b using a shortcut.
I'm not familiar with Sublime but I have heard that it's very similar to Textmate, it may actually be based on Textmate, I'm not sure.
I am familiar with Textmate 1.5 though, and it does have a feature like this which allows you to setup tab triggers and templates by using the built in Bundle Editor.
note: it's worth noting that there is a newer version of Textmate available. I believe the current version is 2.0 but I tried it and decided to stick with 1.5 because 2.0 implemented some major changes and I preferred to stick with what I was familiar and happy with.
A very basic example of how tab triggers can be used in Textmate would be..
<table border="0" cellpadding="$1" cellspacing="0"><tr><td height="$2"><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table></td></tr></table>
This is a simple table spacer that I use in emails rather than using transparent shims. By nesting a table within a table it will prevent it from collapsing and works as a cross-compatible alternative to transparent gif images for email layouts.
By setting this up in Textmate, all I have to do is type tspace followed by a Tab and this code automatically populates at the position of the cursor. Subsequent Tab's will jump the cursor to each $ notation, which is Textmate's own syntax.
So tspace + Tab generates the code, + Tab jumps to $1 where I then fill in the appropriate value, + Tab jumps to $2 where I fill in the appropriate value + Tab jumps to the end of the code block.
note: you can also set it up where any placeholder is repeated so if I notate $1 in more than one location, it will automatically populate everywhere that variable is, the first time I fill it in.
This is only the most basic of examples. There are other similar features in Textmate, and they are only limited by how complex you set them up to be.
Though, as I mentioned, I'm not familiar with Sublime, I did look into it briefly and found this article which outlines the exact same functionality that I've described and how it works within Sublime.

Selenium does not record Ajax Call. Need help on coding in html or selenese

I am recording a .Net application using Selenium IDE. Theres this scenario, that a textbox is presnt. I need to enter a name to search. As soon as i start typing, matching options come in a dropdown below. I have to select one of them, then the application goes to the next page.
The problem is, Selenium doesnt record this selection from the drop down. More over, when the script is typing in the name, the dropdown list is not being visible at all.. i.e. the ajax call is not occuring.
Please help. I need the solution code in Selenese or HTML, since I'm not much of a coder myself, and also, I am simply recording and playback, so I am not using Java or other scripts.
This question is great,
and so is the answer in this blog: http://blog.buberel.org/2010/07/howto-test-jquery-ajax-autocomplete-menus-with-selenium.html
other option to deal with this problem is to use a different way to insert your text into the text box, as described here: Can selenium handle autocomplete?

WYSIWYG html editor query

I am in the process of creating a simple WYSIWYG HTML editor to enable the users of my application to design simple HTML emails.
At the moment I have decided to use the web browser control with MSHTML to enable me to edit what is displayed. I have a tool bar which holds all of the relevant buttons, bold, underline, etc.
I need a way to check if the current block has any formatting so the correct state can be displayed on the buttons in the tool bar. I tried to add an event handler to the IHTMLDocument to fire when the mouse is moved or the arrow keys are pressed, however, this stopped the web browser from taking any input.
Is there a simpler way to achieve this goal?
There are several rich editors for free out of that tinyMCE is one of the better editor.
For list of editors see the link below.
http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors