Community
Participate
Working Groups
It would be great if in the properties file editor there were some way to do the equivalent of the Java "toggle comment" action to add/remove # to the beginning of each line. So, given a file foo.properties: # Neato properties p1=a p2=b p3=c I would like to highlight lines 2-4, select the "Toggle Comment" action (I'd even be happy to have the key combo be the same as the Java editor key combo even though it makes less sense here) and get this result: # Neato properties #p1=a #p2=b #p3=c Selecting the same action again with same lines highlighted would revert to the original version.
Created attachment 70941 [details] patch to org.eclipse.jdt.ui This basic patch hooks into the prefix/unprefix code in the source viewer. It exposes the operation only though command keybindings (no context actions) It does this by registering a new key binding context (editing properties files) and hooking up the existing toggle comment command used in the compilation unit editor. Would it be possible to push down ToggleCommentAction into the text editing layer? The action should work for all languages that have single line comments
>Would it be possible to push down ToggleCommentAction into the text editing >layer? Yes, if we find a more generic name as the generic text framework doesn't have the notion of a comment.
(In reply to comment #2) > >Would it be possible to push down ToggleCommentAction into the text editing > >layer? > Yes, if we find a more generic name as the generic text framework doesn't have > the notion of a comment. > how about TogglePrefixAction? Under the hood it basically wraps the prefix and unprefix text editor operations.
Yes, sounds good. We should then also move the corresponding tests. While moving down, I would probably only create the action in createActions() but not hook it up in the UI for all editors. Can you prepare such a patch?
I will try to create something either tonight or tomorrow. I assume that also means that the command definition and keybindings also get pushed down to text? If the command is pushed down, what should the description be? Most users would not have a clue what a line prefix is. You can work around this by naming the context menu actions as "toggle comment", but you the command will still have the odd name in the keys preference page.
>I will try to create something either tonight or tomorrow. There's no hurry ;-) Looks like it's better not to create the action createActions() for all editors but instead only provide the generic TogglePrefixAction that can then be created by the individual editor with the desired label and description.
Created attachment 71104 [details] patch to org.eclipse.jdt.ui Updated patch. It does not modify the ToggleCommentAction at all as more thought is needed before pushing it down. Instead, I have cleaned up the previous patch and added the action to the context menu (by overriding createEditorContextMenu). It also re-uses the Java toggle comment command instead of creating a new one. Also, the action is not available in the PDE property file editors because they do not activate the new keybinding scope and don't seem to use the PropertyFileEditor directly.
Thanks for the patch. I committed the patch with a few small changes: - added your credentials to the copyright notes - remove "(non-javadoc)" - added @since tags Available in builds > N20071026-0010.