[TxMt] Prefix/Suffix Lines

Allan Odgaard throw-away-1 at macromates.com
Thu Nov 17 18:21:05 UTC 2005


On 17/11/2005, at 18:47, Matt Henderson wrote:

> First question relates to something I frequently did in BBEdit --  
> "Process All Lines", where I might prefix and suffix each line in a  
> selection. Is there a way to do this in TextMate?

When you want to only prefix something, you can use column typing.

This is basically making a (often zero width) column selection and  
then start typing. An easy way to do this is to:
  1) place caret in front of the first line you want to prefix
  2) hold shift and move arrow down till you're at the last line  
(should select them)
  3) click and release the option modifier once, which toggles the  
selection to column mode
  4) start typing (and what you do, is then mirrored on each line).

To make this even faster, you can use option (shift) arrow up/down to  
move up/down a “column”.

To suffix the lines, you would use the Edit Lines in Selection, this  
is done by selecting all the lines affected, and selecting the action  
-- this will place the caret last on the first line, and what you do  
there, will be mirrored, just like with column typing, but this works  
for when the insertion point isn't at the same column for each line.


Another approach is to select your lines and then do a simple regexp  
replace in selection (cmd-F, enable regexp, and ensure the Replace  
All Scope is set to Selection), this would be something like:

  Find: ^.*$
  Replace: «prefix»$0«suffix»

Here ^.*$ matches a line, and $0 refers to the entire line (in the  
replacement string).




More information about the textmate mailing list