Warning: Undefined property: stdClass::$ip in /home/public/blog/class.comment.php on line 31

Warning: Undefined property: stdClass::$ip in /home/public/blog/class.comment.php on line 31

Warning: Undefined property: stdClass::$ip in /home/public/blog/class.comment.php on line 31

Sublime Feature of the Day: Multi-Paste?

Last updated:

(Question mark in title because I'm not sure what to call it.)

Sublime Text has a cool niche feature where you can have multiple selections. Just hit Alt+Shift+Up/Down, and you'll spawn a second cursor in the line above/below your current one. This is useful when you have some code or other data organized into a nice structure, and you want to make the same edits across multiple lines.

What I just discovered today, though, was that multi-select intelligently handles copy/paste, too.

I had a list of urls, and I needed to wrap them in <a>s so that they both linked to the url and displayed it as their text.

  1. Kick off a multi-select for all the lines.
  2. Highlight all of the urls (they were all the same length, luckily)
  3. Ctrl+C
  4. Move back to the beginning of the lines and start typing the <a href=""> part (every line gets this)
  5. Move the cursors to between the "" in the attribute.
  6. Ctrl+V
  7. Boggle.

IT JUST MAGICALLY WORKED. Each line pasted the data from its respective line, rather than (as I feared might happen), each pasting in the entire set of urls, or maybe all pasting the first or last url.

Sublime is one of those delightful and rare programs that just does what you want a surprising amount of the time.

(a limited set of Markdown is supported)

#1 - FremyCompany:

The multi-selection stuff is rather standard on Windows. I do not even remember using any editor not featuring it.

However, the multiline-pasting feature is a nice touch. I just tested and Visual Studio pastes all the urls at all the locations. This behavior actually makes sense if you have only one line of text, but in the case the number of lines matches, Sublime's behavior is actually better!

Reply?

(a limited set of Markdown is supported)

the question is how long have you been using ST and if is more thant a year, how you could live all that time without knowing that!

Just joking, its awesome find "sublime" features in this IDE all the time

Reply?

(a limited set of Markdown is supported)

That is a cool feature. I never tried pasting multiple lines.

I knew about the shortcut, I use it for column selection (Alt + Shift + Down a few rows and then keep Shift pressed and hit Right multiple times until you select the column you wanted). In some editors you can do column selection using middle mouse button (don't have sublime close by to confirm) and it's very useful when you want to replace content on multiple lines or if you want to prefix multiple lines.

Reply?

(a limited set of Markdown is supported)