There is no one command that does this by default, but you can easily replicate this functionality through Komodo macros, see below:
Create a new macro in your toolbox, labeled "duplicate Line" or similar, add the following Javascript code:
// Macro recorded on Tue Jan 30 2007 18?? GMT-0800 (PST)
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };
// Remove any current selection
var currentPos = komodo.editor.currentPos;
komodo.editor.setSel(currentPos, currentPos);
komodo.doCommand('cmd_copy');
komodo.doCommand('cmd_paste');
Then, in the macro properties form, go the "Key Binding" tab and in the "New Key Sequence" press Ctrl-D, then click on the "Add" button to assign the keybinding.
Close the macro, go back to your editing file and try using Ctrl-D.
Note: To create similar macros yourself, take advantage of the Macro recording tools:
Tools->Macros->Start Recording
Go to your editor, hit Ctrl-C (copy) then hit Ctrl-V (paste)
Tools->Macros->Stop Recording
Tools->Macros->Save To Toolbox
For further macro information, check out the Macro API documentation in Komodo's internal help.
Note that Ctrl+C if there is no selection copies the current line. I tend to do Ctrl+C/Ctrl+V to duplicate lines (making sure I have no selection first).
// Macro recorded on Tue May 15 2007 01:18:00 GMT+0200
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };
var ke = komodo.editor;
var savePos = ke.currentPos;
komodo.doCommand('cmd_end')
komodo.doCommand('cmd_selectHome')
komodo.doCommand('cmd_selectHome')
komodo.doCommand('cmd_copy')
komodo.doCommand('cmd_lineNext')
komodo.doCommand('cmd_paste')
komodo.doCommand('cmd_newline')
//komodo.doCommand('cmd_linePrevious')
ke.gotoPos(savePos);
// Macro recorded on Tue May 15 2007 01:18:00 GMT+0200
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };
var ke = komodo.editor;
var savePos = ke.currentPos;
komodo.doCommand('cmd_end')
komodo.doCommand('cmd_newline')
komodo.doCommand('cmd_linePrevious')
komodo.doCommand('cmd_end')
komodo.doCommand('cmd_selectHome')
komodo.doCommand('cmd_selectHome')
new_selection = komodo.interpolate('%s');
komodo.doCommand('cmd_lineNext')
var pos = ke.currentPos;
ke.insertText(pos,new_selection);
ke.gotoPos(savePos);
Even if a copy/paste would do the thing, i found it really helpful.
I was using Notepad++ until yesterday, i do try to use Komodo now and it was a missing feature for me.
I'd like it, moving from Zend Studio I use it a lot (it's on ctrl+D by default there). However, I'd also like to see it duplicate the current line UNLESS there is a section, in which case it should duplicate the selection (be that a couple words or a few lines). Again, it's mostly because that's what I got used to in Zend Studio, but it's really nice to have.
// Duplicate Line or Duplicate Selection
komodo.assertMacroVersion(2);
if (komodo.view) { komodo.view.setFocus() };
var ke = komodo.editor;
if (ko.views.manager.currentView.scimoz.selText){
// Copy the current selection
new_selection = komodo.interpolate('%s');
var pos = ke.currentPos;
ke.insertText(pos,new_selection);
}else {
ke.lineDuplicate();
}
Update: The duplicate line command has been added to Komodo 4.4, though it does not have an assigned keybinding by default. You can search for the command in Komodo's "Editor->Key binding" preferences and assign whatever keys you like.
The duplicate line command is included in Komodo 5, though it is not assigned a keybinding by default.
To assign it, go to your Komodo "Editor->Key Bindings" preferences and search for "duplicate", click on the "Editor: Duplicate Line" entry and then in the "New Key Sequence" field hit Ctrl-D, then click Add.
There is no one command that does this by default, but you can easily replicate this functionality through Komodo macros, see below:
Create a new macro in your toolbox, labeled "duplicate Line" or similar, add the following Javascript code:
// Macro recorded on Tue Jan 30 2007 18?? GMT-0800 (PST) komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; // Remove any current selection var currentPos = komodo.editor.currentPos; komodo.editor.setSel(currentPos, currentPos); komodo.doCommand('cmd_copy'); komodo.doCommand('cmd_paste');Then, in the macro properties form, go the "Key Binding" tab and in the "New Key Sequence" press Ctrl-D, then click on the "Add" button to assign the keybinding.
Close the macro, go back to your editing file and try using Ctrl-D.
Note: To create similar macros yourself, take advantage of the Macro recording tools:
For further macro information, check out the Macro API documentation in Komodo's internal help.
Hope this helps,
Todd
Todd, you're the man. That worked great, thanks!
Note that Ctrl+C if there is no selection copies the current line. I tend to do Ctrl+C/Ctrl+V to duplicate lines (making sure I have no selection first).
It's a controversial feature, FWIW. =)
--david
// Macro recorded on Tue May 15 2007 01:18:00 GMT+0200 komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; komodo.doCommand('cmd_end') komodo.doCommand('cmd_selectHome') komodo.doCommand('cmd_selectHome') komodo.doCommand('cmd_copy') komodo.doCommand('cmd_lineNext') komodo.doCommand('cmd_paste') komodo.doCommand('cmd_newline') komodo.doCommand('cmd_linePrevious')// Macro recorded on Tue May 15 2007 01:18:00 GMT+0200 komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; var ke = komodo.editor; var savePos = ke.currentPos; komodo.doCommand('cmd_end') komodo.doCommand('cmd_selectHome') komodo.doCommand('cmd_selectHome') komodo.doCommand('cmd_copy') komodo.doCommand('cmd_lineNext') komodo.doCommand('cmd_paste') komodo.doCommand('cmd_newline') //komodo.doCommand('cmd_linePrevious') ke.gotoPos(savePos);http://pastie.caboo.se/84357
// Macro recorded on Tue May 15 2007 01:18:00 GMT+0200 komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; var ke = komodo.editor; var savePos = ke.currentPos; komodo.doCommand('cmd_end') komodo.doCommand('cmd_newline') komodo.doCommand('cmd_linePrevious') komodo.doCommand('cmd_end') komodo.doCommand('cmd_selectHome') komodo.doCommand('cmd_selectHome') new_selection = komodo.interpolate('%s'); komodo.doCommand('cmd_lineNext') var pos = ke.currentPos; ke.insertText(pos,new_selection); ke.gotoPos(savePos);Even if a copy/paste would do the thing, i found it really helpful.
I was using Notepad++ until yesterday, i do try to use Komodo now and it was a missing feature for me.
The version not using clipboard is perfect for me, thank you very much
dafi
Enhance KomodoEdit with MoreKomodo
(this is tested on Komodo Edit 4.2.1)
komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; var ke = komodo.editor; ke.lineDuplicate();Good spotting mircho. I did not even know that was already a function of Scintilla.
I've added the following bug to have this command added by default into Komodo:
http://bugs.activestate.com/show_bug.cgi?id=74284
Cheers,
Todd
Does anyone want this duplicate line command to be enabled and assigned by default in Komodo? If so, to what key binding (Ctrl-D, Cmd-D)?
If enough people want it, then we'll turn it on by default. Appreciate your input.
Thanks,
Todd
Ctrl-D to be line duplicate by default :)
I'd like it, moving from Zend Studio I use it a lot (it's on ctrl+D by default there). However, I'd also like to see it duplicate the current line UNLESS there is a section, in which case it should duplicate the selection (be that a couple words or a few lines). Again, it's mostly because that's what I got used to in Zend Studio, but it's really nice to have.
Yes!
Cmd-D to use with Cmd-E (my personalization) to delete a Line
Duplicate line and the move line up and down were the things I missed the most when switched from notepad++
There it was Ctrl+D
I wrote this tiny macro that replicates the current line or selection, see more here:
http://blog.uxebu.com/2008/06/26/duplicate-lineselection-macro-for-komod...
looks like it could be optimized
have fun
Wolfram
// Duplicate Line or Duplicate Selection komodo.assertMacroVersion(2); if (komodo.view) { komodo.view.setFocus() }; var ke = komodo.editor; if (ko.views.manager.currentView.scimoz.selText){ // Copy the current selection new_selection = komodo.interpolate('%s'); var pos = ke.currentPos; ke.insertText(pos,new_selection); }else { ke.lineDuplicate(); }chemiX // http://www.chemix.cz
Update: The duplicate line command has been added to Komodo 4.4, though it does not have an assigned keybinding by default. You can search for the command in Komodo's "Editor->Key binding" preferences and assign whatever keys you like.
I opened an enhancement request (bug 78819) to make it duplicate the current line OR the currently selected text (if there is any).
Hi all, I was looking for:
But couldn't find in Komodo Edit 5... This was one of the features of Notepad++ I miss the most, so I decided to make a plugin, please check here:
MoreNppKomodo
http://code.google.com/p/morenppkomodo/wiki/StartPage?tm=6
There's a bit of a discussion there too... The source is given as a Komodo Edit project, that compiles within Komodo Edit 5. Any feedback welcome...
The duplicate line command is included in Komodo 5, though it is not assigned a keybinding by default.
To assign it, go to your Komodo "Editor->Key Bindings" preferences and search for "duplicate", click on the "Editor: Duplicate Line" entry and then in the "New Key Sequence" field hit Ctrl-D, then click Add.
Cheers,
Todd