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.

Hi is there a text editor out there that allows me to select a block of text and insert a character to all lines at where I want to? E.g. start of line, end of line, nth position

share|improve this question
add comment

4 Answers 4

Yes, there should be many who support this.

In vim you could do that in multiple ways:

  • select a visual block with CTRLV and insert with I
  • use a regex: :1,$s/^/your text here/

which reminds me that you could directly use the regex with sed (i.e. on the shell).

$ sed -i 's/^/your text here/' $YOUR_FILE_HERE

I believe in emacs this is called M-x string-insert-rectangle.

share|improve this answer
    
Okay I've downloaded Vim, but this method of selecting with CTRL V isn't working out... I've never used Vim before. –  FlavorOfLife Sep 25 '10 at 5:59
    
Or use regex...? –  FlavorOfLife Sep 25 '10 at 6:00
3  
you should go through the vim tutorial. it's in the vim folder in your programs menu. Vim and Emacs are entirely new ways of thinking about editing text. And regex ... is not for the faint-hearted. –  robertpateii Sep 25 '10 at 6:43
    
What OS are you using? Vim on Windows is defaultly configured to use Ctrl-V for paste and Ctrl-Q for the purpose given above. –  garyjohn Sep 25 '10 at 16:07
    
In vim, 1,$ can be substituted with %. In ed, the entire file is , –  grawity Sep 25 '10 at 17:37
show 1 more comment

is there a text editor out there that allows me to

Yes, Emacs.

select a block of text and insert a character to all lines at where I want to? E.g. start of line, end of line, nth position

To insert some text at the Nth column: select the block of text from the Nth column of the first target line to the Nth column of the target last line, then press C-x r t (string-rectangle) and enter the additional text to insert on every line.

To insert some text at the end of the line: select the block of text down to the end of the last line, then run M-x replace-regexp (or press C-M-% or choose “Replace regexp” in the “Edit” menu) to replace the regexp $ (meaning end of line) with the text you want to insert.

(C-x means Ctrl+X; M-x means `Alt+X)

share|improve this answer
2  
"Yes, Emacs" Hehehehehehe.... –  dmckee Sep 25 '10 at 17:32
add comment

If you don't mind paying for an editor UltraEdit calls that feature "Column Mode". UltraEdit is for Windows & Linux.

If you are on Windows, I believe there are some freeware text editors with that feature, but I can't recall their names right now. If I find them I will update my answer.

share|improve this answer
    
Nice, I've also been looking for something like column mode. Can you explain further? Say I create some kind of 'table' in plain text would I be able to edit a column? –  FlavorOfLife Sep 26 '10 at 9:47
    
Here is a link ultraedit.com/support/tutorials_power_tips/ultraedit/… I hope this helps. –  Scott McClenning Sep 27 '10 at 5:19
add comment

You can achieve this with jEdit.

To select a block of text use the Rectangular Selection tool (i.e. hold down Control while selecting)

The Search/Replace tool allows you to search using regular expressions so to find the start of every line the search criteria would simply be "^"

share|improve this answer
    
Another excellent suggestion, but this looks more for the programmer breed. Ahh so many text editors out there! –  FlavorOfLife Sep 26 '10 at 9:48
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.