Eliminating double, triple, quadruple, etc. spaces in MS Word - ms-word

I receive a lot of text files like this
120
1
230
1.3
3
13240
7
In addition, there is some regular text there too (single space between the words). So I would like to come up with a way to automatically "search and replace" two, three, four, five, etc. spaces (all but single spaces) so that the above numbers no longer have any spaces in front of them. Any thoughts? Maybe a macro would help?

You don't need a macro, actually, this can be done simply with the Find and Replace tool.
Open the Find and Replace dialog box (control+H by default).
If the Search Options section is not currently displayed, press the "More > >" button to display it.
In the Search Options section, check the "Use wildcards" checkbox.
In the "Find what:" field, enter a single space followed by {2,} .
In the "Replace with:" field, either leave it blank to remove the leading spaces entirely or put a single space to replace all repeated spaces with a single one.
Press the Replace All button.
Note that if you choose to remove leading spaces entirely, this may backfire if you have any lines beginning with just a single space; these will still have the space there, while the ones that used to have multiple spaces at the beginning will have them all removed.

Related

How can I globally search tab characters in VSCode?

I would like to keep all my C/C++ code files using space for indentation. There are existing source files, most of them are with space indentation, but some lines are with tab character.
I would like to globally search all the tab characters in all .h/.hpp/.c/.cpp files, replace them with space.How can I do that?
I've tried use ^t but not working.
For example, line 79 and 80 starts with tab character, should be replace with space:
But if search globally, these lines are not found, but found other lines:
Seems I asked an silly question.. I just forgot to click "use regular expression". After choosing that, it finds what I want.

Copy Lines including carriage return linefeed in notepad++

Using Notepad++ I want to select individual, non-contiguous lines, copy them, and past them and include the CR/LF at the end. Preferrably, I would hold Ctrl, then click the line numbers I want, then press Ctrl+C or right click and select copy; however doing this selects all text (which is frustrating and doesn't make much sense). Furthermore, only selecting the line partially includes the line below it, so that if i press Ctrl+Shift+Up(or down) the line below it also moves up or down.
In summary, I want to copy non-contiguous lines and past them with their respective EOL characters.
Use Ctrl+F2 to mark desired lines.
Menu Search > Bookmarks > Copy bookmarked lines will copy these lines into clipboard.
As option for step 1, you can use Mark tab of Find dialog (Ctrl+F) with Mark Line option checked.

tinymce removes extra spaces

I have a text area tinymce file that removes extra spaces and I don't want that.
For example if in the text area if I put hello, 5 spaces, bye, and when I save the file and view it again, 4 spaces are deleted and I see hello bye. (4 extra spaces are deleted)
Sorry if I sound not too informed about this, but I just wonder if this is a default feature or if there is an easy way to turn off this feature. (I do not want the extra spaces to be deleted.)
Thanks,
The issue here is that modern browsers will not display several spaces - but will show them as one single space. The solution here is to replace every second space with a " " before the content gets into the editor (best is to replace them on serverside). This way the browser will show all the spaces.

How to do search and replace involving fields in Microsoft Word?

I have a Word document with fields of the reference variety, which occur in the form "[field].[field]"--in other words, there's a period between the two fields. I want to globally replace this with a space.
Word offers the ^d special character to search for fields, but for some reason the query "^d.^d" does not find anything. However, ".^d" does. Now comes the problem, however--what do I specify as the replacement text in order to retain the field code? If using regular expressions, I could use a "Find What Expression" such as \1, but with regexp ("wild card") mode the ^d is not permitted.
I guess I could write a macro...
I would like to add to Bibadia's solution.
An example of an index entry field; we want to change a name we misspelled.
Make sure hidden formatting is displayed (toggle with SHIFT+CTRL+F8).
Make sure wildcards option is not selected. To search for fields, use the opening and closing field braces code (optionally use ^w for spaces, as Bibadia suggested):^19 XE "Deo, John" ^21
Replace won't recognize field braces character, but will allow to insert the clipboard's content. ;). To do that, insert in text the correct entry. CTRL+F9 to insert field and type:XE "Doe, John"
Select the field above and copy
Use ^c in the replace box
Hit Replace All
Ta-da!
It's usually better to go the macro route when finding fields because, as you say, the find algorithm that Word uses doesn't work the way you might hope with fields.
But if you know exactly what the fields contain, you can specify a search pattern that will probably work (however not in wildcard mode).
For example, if you want to look for figure number field pairs such as
{ STYLEREF 1 \s }.{ SEQ Figure \* ARABIC \s 1 }
(which would typically be the same set of fields everywhere in the document)
If you only really need to look for the following:
{ STYLEREF 1 \s }.<any field>
you could ensure that field codes are displayed and search for
^d STYLEREF 1 \s ^21.^d
or
^19 STYLEREF 1 \s ^21.^19
If you need to be more precise, you can spell out the second field as well.
"^d" only works for finding the field beginning, not the field end.
It's a shame that ^w wants to find at least 1 whitespace character because otherwise it would be more robust to look for
^19^wSTYLEREF^w1^w\s^w^21.^19
Perhaps someone else knows how to work around that without using wildcards?
Torzaburo,
I suggest that you do this using a macro. You can start by recording the macro, and later refining your processing steps within the macro.
First turn on the hidden characters by navigating to Home > Paragraph > toggle the show/hide Paragraph symbol. Also, select all and toggle the field codes on (right-click and select "Toggle Field Codes".
Open a new blank Word doc in addition to the one you have open. You will use this later. Start the macro recording and find the field using the "^d" (field code) as you said.
When the field is found, copy only the field text within the brackets, and not the full field reference. While the macro is still recording, ALT + TAB to the new blank document and paste the field code in as plain text.
At this point, do the necessary find & replace processing to the field codes. Highlight the processed field codes, copy, ALT + TAB back to the original document, and paste back between the { } brackets.
Stop the macro recording. Add any further custom processing to the macro VBA.
Select-All and re-toggle the field codes. Update the field codes.
You don't need a macro. Just toggle all field codes on by using Alt+F9. Then do a find and replace for what you want to change. Once the replacement is complete, use Alt+F9 again to toggle the field codes back off.
Disclaimer: I didn't originate this solution, but it's clean and elegant and I thought it should be included here:
(Adapted from Search & Replace Field Codes in Word):
Create or find a single instance of the field you want to convert text to
Toggle Field Codes visible (AltF9)
Copy the code for the field you want to use to the Clipboard (highlight and CtrlC)
Open the Replace dialog box (CtrlH), insert the text you want to replace in the Find What box and then enter ^c in the Replace With box.
This will replace your text with the contents of the Clipboard, turning it into the field code you copied in step 3. It also copies formatting information (font, color, etc.), to control how the field will appear when hidden. (Caveat: I've tested this with Word 2003 under Windows 7 only.)
Coming in late on this, probably way too late for Beth (sorry Beth). And this may not be quite what Beth was looking for. But for anyone interested ...
It sounds like Beth may have created captions throughout the document using INSERT CAPTION (hence the presence of field codes). This means these captions will have been (automatically) created in CAPTION style.
To globally replace the separator "." with " " (space) in such captions, take two steps:
[1] Go to REFERENCES | INSERT CAPTION, then click on NUMBERING and replace the SEPARATOR "." with "EM-DASH". This will replace all separators in captions for the selected label in the CAPTION Window. If you have other labels in use in the document (e.g. FIGURE), select the other labels one by one and repeat this process.
[2] Do a find/replace searching for special character "em-dash" (^+) in style CAPTION, replacing with " ". Click REPLACE ALL.
Voila!
NOTE: This presumes that em-dash does not appear in the caption text anywhere. If it does, then you'll need to do a pre- and post- "fiddle" to ensure these em-dashes are not touched by the global replace above.
The "pre-fiddle" is to do a global find/replace across captions, replacing the em-dash ("^+") with some other string (e.g. "EM-DASH") that doesn't ever occur in any caption's text. Then you do the separator change as described above. Finally, the "post-fiddle" is to restore the em-dashes that were in the captions, by doing a global replace of the string "EM-DASH" with the actual em-dash character "^+".

Is there a way to get Eclipse to treat 4 spaces exactly as it treats a tab?

I understand how to get Eclipse to insert spaces in place of tabs, but then I'd rather not have to arrow through 12 spaces to reach an indented block.
Bonus points if there's a way to hide the spaces from the 'show whitespace characters'. I like to see whitespace characters for tabs and carriage returns, but the display gets too cluttered when spaces are also displayed.
Try CTRL+[right,left] arrow key. Certainly one of my most-used combos.
As it turns out, this appears to not be possible in Eclipse.
With the next Eclipse 20199.12/4.14, that might actually be possible! (albeit ten years later)
See "Backspace/delete can treat spaces as tabs"
If you use the Insert spaces for tabs option, now you can also change the backspace and delete keys behavior to remove multiple spaces at once, as if they were a tab.
The new setting is called Remove multiple spaces on backspace/delete and is found on the General > Editors > Text Editors preference page.