sublime text select first in each line

Supposing you have the following text:

my.property.link1=<a href="asdfs">Link 1</a>
my.property.link22=<a href="asdfs">Link 22</a>
my.property.link333=<a href="asdfs">Link 333</a>
my.property.link4444=<a href="asdfs">Link 4444</a>

Press Ctrl + F (or click Find->Find)

Enable regular expressions

Type in the search field: ^.*?(?==)

Preess Alt + Enter (or click Find All)

Now all the text before = is selected, you just need to copy it.


I actually wrote a sublime plugin called SelectUntil that addresses this exact problem: https://github.com/xavi-/sublime-selectuntil

Once it's install you can do the following

  • Select all the line you'd like edit or partially copy
  • Press Cmd/Ctrl + Shift + L -- this gives each line it's own cursor.
  • Bring each cursor to the beginning of it's line by pressing Home or Ctrl + A if you're using OSX
  • Press Ctrl/Alt + Shift + S to activate SelectUntil
  • Tell SelectUntil to select until the equals sign by typing = + Enter
  • Hit shift + to deselect the equals sign
  • At this point the names of all the properties should be selected so you can copy/paste as you'd like

The experience should look something like this:

enter image description here


[CTRL + A] ; [CTRL + Shift + L] ; [Home]

make a AutoItInputMacro.exe Map that to [Home] 1 press button GG No rematch.


Tried this and it seems to work:

Regex find using ^(.*)(STRING_TO_MATCH)

\1 will give all the stuff before your match, \2 gives the match itself.

You could also use ^(.*)(STRING_TO_MATCH)(.*) and then \3 would be everything after.

Edit - if you're looking to select and copy, I tried this: ^[^CHAR]*

This will find everything from the beginning of the line up to and not including your character. From there you can right click to copy. I haven't found a keystroke sequence to do it since the find panel has focus, maybe you can figure it out.

Tags:

Sublimetext2