TextWrangler - move text to the end of the line - sorting

I have a text file containing only text lines like this:
(abc) defghjklmnop
I want the whole bracket to be at the end. So it should look like this:
defghjklmnop (abc)
The text in the bracket and the text after it vary from line to line.
How can I do this in TextWrangler?

Search for this:
(\(.*\))(\s)(.*)
and replace it with this (using back references to the groups in parentheses above):
\3\2\1
This will also preserve the whitespace between the two groups.

Related

Remove duplicates lines but not blank lines in Sublime Text

I know that you can remove duplicate lines by doing Edit>Permute Lines>Unique. But that will remove blank(empty) lines. I would like not to remove them, so blank lines will stay(essentially empty space).
You can do this using Permute Selections. First, open the Find menu (CtrlF or Find → Find…) and make sure the Regex, Wrap, and Highlight matches buttons are selected. In the search field, enter ^.+\n. This matches the beginning of the line ^, 1 or more characters of any type .+, and the newline character(s). Therefore, it will select any line that is NOT just a newline. Note that this will select lines that contain only whitespace, for example a tab character followed by a newline.
Next, hit the Find All button to select each line individually.
Finally, select Edit → Permute Selections → Unique and all duplicate lines will be erased, leaving all blank lines behind.

InDesign data merge—"remove blank lines" resulting in extra characters

I'm using data merge to import two variables per line, and have checked the "Remove blank lines for empty fields" box. The result is a wealth of extra characters that I can't remove using find-and-replace. Of the 24 lines of variables, typically only three contain text, so the other 21 should be empty lines and be deleted by the "Remove blank lines" option.
Attempting to paste these characters into the "find and replace" field, I see
^|^|^|^|^|^|^|^|^|^|^|^|^|^|
Any suggestions? Thanks
Try doing a regular text find/change.
In the Find What field, type < FEFF > (but delete the spaces before and after those angle brackets – the Stack Overflow editor seems to delete this if there are no spaces).
In the Change To, leave blank, and click change all.

Beyond compare ignore one side comments

I found some instructions on how to show/hide differences in comments using beyond compare. However most of the answers show how to set comment as important text or not. That is, if a portion of code is commented on both sides then check if the comment are different or not.
I would like to ignore when only one side of the comparison is commented. In other words if I have
# # line1
# line2
on one side and
# line1
line2
I would like both lines to be marked as "unimportant differences" (if indeed the text is the same, otherwise to be marked as differences).
Beyond Compare will only compare text if it is of the same grammar element type. If one side is regular code and the other side is a comment, it will always mark it as an important difference.
To make regular text on one side and the same text commented on the other side show as a match, you'll need to edit the definition of a comment in the file format.
To edit a format, open Tools > File Formats.
Select the format that matches your files.
Go to the Grammar tab.
Select the Comment grammar element, which might be defined as # to end of line.
Click the Edit (gear) button.
Set the Category radio button to Basic.
Text matching: ^#\s
Check Regular expression.
Click OK, then Save.
The updated file format will treat # followed by a whitespace character as an unimportant comment, the remaining text in the line will be treated as regular text and compared to the other side.

Remove all lines containing a specific string

I have a big file and I want to remove all the lines that have the word date
For example:
{
date: 10291992
stuff: stuff
...
},
{
date: 02171995
stuff: stuff
...
},
...
So I want to remove all the lines that contains the word date but since each date has a different date, I can't just ctrl f and replace it. I was reading that putting ^.* in the front but it didn't work for me.
I'm currently using Sublime Text 3.
Thanks.
All you need to do is open the Find dialog (Find -> Find...), search for date, hit Find All to select all instances of your search pattern, then select Selection -> Expand Selection to Line. Hit Delete and you're all done.
I tried to follow the accepted answer but found it wasn't working for me: the Expand Selection to Line button was not expanding the selection for all the matched lines.
What did work, though, was to switch to regular expression mode (the *. button on the left of the Find menu) and do a search for
\n.+date.+
replacing it with an empty string. This removes the entire line (i.e., doesn't leave an empty line in its place).
Or faster: highlight date, hit Alt+F3 to Quick Find All, then Ctrl+X twice to delete the line.

Put a cursor to a beginning of each line

Is there any way to put a cursor to a beginning of each line in Sublime Text, given that the beginning of each line is different so it's impossible to do a search by a pattern and then select all the occurrences? I want to do that without any plugin.
An alternative to MattDMo's answer could be to select all (ctrlA), then split selection into lines (ctrlshiftL), then move to the beginning of the line (home) to get the cursors in the proper position and cancel out the selection.
This would avoid the regex search.
Do a regex search for \n, then hit Find All (AltEnter) to select all the newline characters (the very end of each line). Next, hit ← to remove the selections, which places the cursors at the end of each line. Finally, hit Home twice to move the cursors to the beginning of each line.

Resources