I have a series of lines in LibreOffice/OpenOffice, formatted like so:
title(tab)data1(tab)data2(tab)data3
(tab) is an actual tab character.
What I would like to be able to do is:
prepend the line with "____ "
bold "title"
remove the first (tab), and surround data1 with brackets []
change the second (tab) to ": "
remove the third tab, and surround data3 with brackets []
The lines would hopefully end up as:
____ title [data1]: data2 [data3]
How can this happen?
Go to Edit -> Find and Replace:
Enter in the "Search For" box: ^([a-z0-9 ]+)\t([a-z0-9 ]+)\t([a-z0-9 ]+)\t([a-z0-9 ]+)$. Adjust this expression if the titles or data contain other characters such as punctuation. Documentation is here.
Enter in the "Replace With" box: ____ $1 [$2]: $3 [$4]
Expand "Other Options" and check Regular expressions.
Press Replace All to perform the replacement.
Then, bold the title as follows:
Search for: (?<=____)([a-z0-9 ]+) (?=\[)
Press the Find All button and close the dialog.
Now all the titles should be selected. Press the button in the toolbar to bold the text.
Related
I am aware about surrounding selection in quotes or braces
PhpStorm wrap/surround selection?
I need similar but surround selection into array
Assume I have text separated with newline or text separated with space
a
b
c
d
e
a b c d e
I need after selection get [a,b,c,d,e]
Please advice any IDE or method how to achieve this
A no-brainer solution
Make sure the following option is enabled:
For text separated with spaces:
Select the 'array-to-be', hit Ctrl+R and R again (to enter 'In selection' mode)
Type a space in the first field, , in the second
Click 'Replace all', hit Esc
With the text still selected, press [: the closing bracket will be added automatically
For multi-line text:
Select the 'array-to-be', hit Ctrl+R, enable 'Regex'
Type \n + in the first field, , in the second
Click 'Replace all', hit Esc
With the text still selected, press [: the closing bracket will be added automatically
The sequence of actions can be wrapped into a macro and assigned a single shortcut.
Vim + Surround plugin. Enter visual mode, select what you need and press S].
The first group could be created by:
:%s/\v(\w)(\n)*/\1,/g | exec "norm! I[\<Esc>A]"
It takes care of:
a
b
...
\v ........... very magic regex
() ........... regex group
(\w) ......... letters
(\n)* ........ zero or more line breaks
\1 ........... repeat content of the first regex group
I am trying to remove all whitespace using Intellij IDEA Ultimate 2019.1.2. I have a simple text file with json data.
I've tried using find and replace with regex enabled, but to no avail.
You can press the CTRL + R to open the replace panel, and enter a whitespace in the first input field, leave the second input field empty.
Then click the replace all button.
If you want remove all whitespace including line break, you can enter \s and enable the regex option.
I'm newbie in VBA. I would like to find all bold text and insert brackets before and after it.
For example, Before: This is bold text
After: {This is bold text}
I'm using MS Word
You don’t need to use VBA; Word’s UI can do it directly with Find and Replace:
Leave the “Find what” box empty, but press Ctrl-B to specify Format: Font: Bold. (You can also click the More >> button to access the Format drop-down button and select Bold from the Font dialog.)
In the “Replace with” box, type ^& (or you could type the asterisk, use the Special drop-down to choose “Find What Text”, and type the 2nd asterisk).
Click Replace All.
Each instance of bold will be “replaced” by an asterisk, the found content (i.e. the bold letter(s)), and another asterisk.
Edit: The ^& is a special code to represent “Find What Text” as a Replace option in Find and Replace. The “Special” button presents a list of available options by name for both the Find and Replace boxes, and will insert the code when you make the selection.
Id like to add .pdf text after
these characters: =pd
and after 6 characters behind characters above in Notepad++
for example:
for text:
=pd374069
=pd422552
add suffix:
=pd374069.pdf
=pd422552.pdf
Press ctrl+h or go into the find/replace window. Select Replace tab and choose the Regular Expression option.
In the find text box enter (=pd\d{6}(?!\d))
In the replace window enter \1\.pdf
It will transform
SPEC SHEET=pd374053;MANUAL=pd374069;SPEC SHEET=pd422552
into
SPEC SHEET=pd374053.pdf;MANUAL=pd374069.pdf;SPEC SHEET=pd422552.pdf
I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line.
test line one
test line two
test line three
test line four
...
Say you have 100 lines of text in the editor, and you want to paste quotation marks to the beginning and end of each line.
Is there an easy way to do this or a plugin that anyone would know of? This would often save me a lot of time on various projects.
Thanks.
Yeah Regex is cool, but there are other alternative.
Select all the lines you want to prefix or suffix
Goto menu Selection -> Split into Lines (Cmd/Ctrl + Shift + L)
This allows you to edit multiple lines at once. Now you can add *Quotes (") or anything * at start and end of each lines.
Here's the workflow I use all the time, using the keyboard only
Ctrl/Cmd + A Select All
Ctrl/Cmd + Shift + L Split into Lines
' Surround every line with quotes
Note that this doesn't work if there are blank lines in the selection.
Select all the lines on which you want to add prefix or suffix. (But if you want to add prefix or suffix to only specific lines, you can use ctrl+Left mouse button to create multiple cursors.)
Push Ctrl+Shift+L.
Push Home key and add prefix.
Push End key and add suffix.
Note, disable wordwrap, otherwise it will not work properly if your lines are longer than sublime's width.
Let's say you have these lines of code:
test line one
test line two
test line three
test line four
Using Search and Replace Ctrl+H with Regex let's find this: ^ and replace it with ", we'll have this:
"test line one
"test line two
"test line three
"test line four
Now let's search this: $ and replace it with ", now we'll have this:
"test line one"
"test line two"
"test line three"
"test line four"
You can use the Search & Replace feature with this regex ^([\w\d\_\.\s\-]*)$ to find text and the replaced text is "$1".
Use column selection. Column selection is one of the unique features of Sublime2; it is used to give you multiple matched cursors (tutorial here). To get multiple cursors, do one of the following:
Mouse:
Hold down the shift (Windows/Linux) or option key (Mac) while selecting a region with the mouse.
Clicking middle mouse button (or scroll) will select as a column also.
Keyboard:
Select the desired region.
Type control+shift+L (Windows/Linux) or command+shift+L (Mac)
You now have multiple lines selected, so you could type a quotation mark at the beginning and end of each line. It would be better to take advantage of Sublime's capabilities, and just type ". When you do this, Sublime automatically quotes the selected text.
Type esc to exit multiple cursor mode.
Select all lines you want to add a suffix or prefix.(command+ A to select all the lines)
Press command+shift+L. This will put one cursor at the end of every line and all the selected lines would still be selected.
For adding suffix press command+right and for adding prefix command+left. This will deselect all the earlier selected text and there will only be cursors at the end or start of every line.
Add required text