Sublime Forum

Duplicating lines with values replaced

#1

Ok… crazy question time. I seem to have discovered a feature, but I can’t make it work again. Does it really exist, and if so what’s the key shortcut I accidentally pressed?

I had this line:

'company_name'  => $this->input->post('company_name', true),

I’d added a new variable lower down the code: “company_address”. I needed to add a duplicate of the above line and amend it accordingly.

I put the cursor on the company_name line, hit Ctrl-L, then - I thought - hit Ctrl-Shift-D.

Instead of an exact copy of the line appearing below it, I got the new line with the new variable name in it. As in, I magically got:

'company_address'  => $this->input->post('company_address', true),

It’s likely that the string “company_address” was copied to my clipboard at the time. Prior to my selecting the company_name line, it was probably the selected text in the editor window.

However, I cannot reproduce this. And I can’t see it mentioned anywhere in the documentation.

Was I dreaming? Can sublime do an intelligent-line-duplication-with-parametric-replacement-thing? Is my computer better at coding than me?

Aaaaagh. Help.

0 Likes

#2

It was magic, or some plugin I desperately want to know about.
Possible repro:
ctrl+l
ctrl+shift+d
right arrow
ctrl+d
ctrl+d
ctrl+v (assuming “company_address” was in your clipboard)

so… maybe you pressed a few more buttons than you thought? :smile: If it is a plugin, though, let me know!

For reference, DuplicateLine.py, which comes with Sublime Text 2, does nothing above or beyond duplicating the line.

0 Likes