I don’t remember which IDE it was that made me learn to use the shortcuts (may be Turbo Pascal back then), and (almost) since then I am too lazy to learn new shortcuts. Now I always first customize the keyboard shortcuts.
And already for a long time I am missing Ctrl+D/Apple+D for Komodo Edit which I use for editing JavaScript, CSS and HTML. This shortcut is supposed to duplicate either the current line or the entire selection. To make a long story short, here is the screencast video (1:04 min) that shows you how to apply the macro shown below.
Since there seems to be no native implementation of that in Komodo I just took some JavaScript skills and the time to look into the macro stuff, and found out that it is actually pretty easy. After looking at the macro API doc to find out how to differentiate if something is selected or not. It was as simple as recording the two macros and mixing them together, surrounded by an “if” that does the job right for the selection and the other for the current line. And I was done.
This is the end result. Just create a new macro and put the source there (the video shows how to do that in detail).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Duplicate line/selection macro, more info at // http://blog.uxebu.com/2008/06/26/duplicate-lineselection-macro-for-komodo/ komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; if (ko.views.manager.currentView.scimoz.selText){ // Copy the current selection komodo.doCommand('cmd_copy') komodo.doCommand('cmd_lineNext') komodo.doCommand('cmd_linePrevious') komodo.doCommand('cmd_paste') } else { // Copy the current line komodo.doCommand('cmd_homeAbsolute') komodo.doCommand('cmd_selectLineNext') komodo.doCommand('cmd_copy') komodo.doCommand('cmd_paste') komodo.doCommand('cmd_paste') komodo.doCommand('cmd_linePrevious') } |
Have fun duplicating …
Comments
[Manual Trackback] :) How to enable this feature in Eclipse/Aptana: http://www.mahner.org/weblog/zeile-verdoppeln-eclipse/
July 24, 2008 — 02:52 pm
Martin
Thanks a lot! I missed this feature after migrating to Komodo from Nuspere!
BTW: Komodo itself has Duplicate LINE (but not SELECTION) feature, but it is insufficient for me.
December 3, 2008 — 08:57 am
ThyBzi
Прикольная тема, продолжайте. Иногда нахожу ответы, которые получить самому просто реально не хватает времени. Большое спасибо!
April 6, 2010 — 04:01 am
Postfix
Однако, вебмастер ништяк накреативил.
April 27, 2010 — 11:59 pm
Forex Inside
Thanks for this, I didn’t know you could do this in Komodo anyway. But hitting Ctrl-D is nicer than Ctrl-C Ctrl-V.
January 28, 2011 — 07:29 pm
Dan
With the current version of komodo edit, you can easily go:
edit / preferences
editor / key bindings
then type in dup in commands, you will be short-listed with the ‘duplicate line’ and ‘duplicate line or selection’ commands, from where you can assign a keyboard shortcut.
July 11, 2011 — 02:04 am
dave