开发者

In TextMate is there an easy way to swap two comma-separated values?

开发者 https://www.devze.com 2023-03-19 03:45 出处:网络
Let\'s say I have the following: [\'cart\', \'horse\'] Is there a quick way to swap the two so I have the following:

Let's say I have the following:

['cart', 'horse']

Is there a quick way to swap the two so I have the following:

['horse', 'cart']

I'm referring to the actual text a开发者_JAVA百科nd not reordering an array programmatically. For example, I usually do something like this:

  1. Highlight and cut " 'horse'"
  2. Delete the trailing comma
  3. Paste " 'horse'" before "'cart'"
  4. Delete the leading space
  5. Add ", " after "'horse'"

I find myself needing to do this type of thing frequently, so I'm wondering if TextMate has some type of built-in functionality/bundle for accomplishing this.

Thanks.


When I have to do something like this, I will use regular expressions in the Search & Replace dialog.

Search for: '(.*)', '(.*)'

Replace with: '$2', '$1'

And make sure that the "Regular Expression" box is ticked. There may be a bundle that can help out with this, but I often find it easier to write a quick regex to reorder/rearrange.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号