Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Textmate, I am able to add text to several lines at once by clicking and holding the Option key and dragging with the mouse. say I have the following lines:

foo 1: 
foo 2:
foo 3:

I can easily click and hold option and then drag down with the lines to select the text at the end of each line, and then type "bar" once and it will be added to all lines, as such:

foo 1: bar
foo 2: bar
foo 3: bar

Fantastic.

The problem I run into, is when my lines aren't the same length, as such

foo 19: 
foo 37842342346: 
foo 503: 

Now if I want to add text to the end of each line, I have to either do it manually, or choose enough space so that the longest line is not overwritten, as such:

foo 19:          bar
foo 37842342346: bar 
foo 503:         bar

This results in a lot of unwanted whitespace in lines that don't need it. Granted, I could easily run a regular expression search to replace all multiple occurrences of a space with a single one, but I was wondering if there's a way to select all ending of lines at once without having to do that.

Any idea?

Thanks!

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

Select all the lines you want to edit then type + + a. You will be able to edit each line simultaneously.

The command is called "Edit Each Line in Selection" and can be found in the "Text" menu.

share|improve this answer
    
perfect! that's exactly what I wanted. thank you so much! :) –  Yuval Jan 4 '11 at 4:04
1  
Nice!. But note that this is superseded for Textmate 2: See below, or also this youtube screen cast d.pr/9rBS –  tim Jul 3 '13 at 10:16
    
@tim: I'll believe you by default, I've stopped using TextMate a long time ago. –  romainl Jul 3 '13 at 10:49
add comment

In textmate 2, make a vertical multiline selection (just ⇧-↓ to select multiple lines then ''tap'' the option key to make a vertical selection)

Now.. just move to the end of the line (⌘→) - boom! you can edit the end of each line!

Lorem ipsum dolor, ADDED THIS TO EACH !!
consectetur, ADDED THIS TO EACH !!
do eiusmod tempor incididunt, ADDED THIS TO EACH !!

See this screencast for more info http://d.pr/9rBS

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.