How to insert/copy+paste unicode whitespace into a text file using editors like Textmate? - macos

I am trying to create a test csv file for a file cleaning script that is supposed to normalize all whitespace into "normal"/ "regular" whitespace character. The idea is I will insert a bunch of these oddball whitespace characters into this test file in some various locations.
Here are some sites that show these various and oddball whitespaces
https://en.wikipedia.org/wiki/Whitespace_character
http://jkorpela.fi/chars/spaces.html
I've tried to copy and paste from sources like that website but it seems like they always paste in as a normal space in Textmate. It could be that I am not copying what I think I am copying. In the past I've been able to copy and paste into Textmate special / unicode characters when I can clearly see what I am copying but with whitespace characters, I can't confirm since I can can't see it, so I am not sure if the problem is where I am copying from or that Textmate is converting it to the normal space when I paste it in.
If it is easier to use Textedit (the built in editor) or nano (command line editor) to do this I could use those. Or if there is another way other than copying and pasting that is better to get these into Textmate that would be an option.
I am on a MacbookPro running High Sierra MacOS.

If you have LibreOffice installed you can use the spreadsheet application to create these using their hexidecimal equivalent in 1 cell then doing a conversion using
=unichar(hex2dec(cell_ref_to_1rst_cell)).
Far less confusing and you can save the spreadsheet complete with comments as a handy reference. Then you should just be able to copy paste the cell with the unicode character when required.

If you’re using TextMate, various functions provided by the Unicode bundle could be helpful here (install via Preferences → Bundles → Unicode).
With this bundle installed you can use Insert Unicode Character ⌃⌥⌘I to insert a character by name. Search for “space” to get a list of all space characters, then simply click on the desired character (the full title of a character is shown on hover):
Of course once inserted all the space characters look almost identical. To identify them, use Show Unicode Name(s) ⌃⌥⌘U 6. This will display a tooltip showing the unicode of name of the character directly before the cursor (or the names of all selected characters, if a selection is active).
Also have a look at Show Character Inventory (press ⌃⌥⌘U and then select the command from the popup menu): This provides a convenient overview of all the characters in your document (or in the selected text, if a selection is active).

Related

How to change the list of characters that MacOS QuickLook displays when previewing font files (ttf, otf etc)

By default MacOS's built in QuickLook feature displays only latin characters + figures when previewing font files. This is what it looks like:
typical QuickLook preview window for a font file
I need to be able to quickly see if the font contains non-latin characters, for example Cyrillic. I am sure there is a way to edit some .plist file inside macOS to modify the list of characters that QuickLook shows for a font in order to add some non latin characters. I even did it once, but it was a few releases of MacOS ago, when System and Library folders were not hidden and thus were searchable.
Could someone please advise, where this .plist file may be located now in MacOS (HighSierra)? Thanks!
Found a solution myself:
The various character sets that QuickLook presents are based on the language which is the primary language you are using. The character sets are are kept in a file called SampleSupport.plist which is found at:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/Resources
Copy this path and in Finder go: Command + Shift + G and paste the path into the field and you will instantly brought to the right place.
Edit the file in your favourite editor. Edit the EN char string to add some non-latin chars.
editing SampleSupport.plist to show non-latin characters

Notepad++ convert leading spaces to tabs upon entry

Very close to reverse of this question. I prefer coding with 2-whitespace indentation, but need to have files indented with tabs to align with project convention. What I would like to do is preferably automatically convert 2 spaces upon entry to tab symbol in Notepad++ and have the editor configured to tab length of 2.
A possible manual way for doing this could be Edit->Blank Operations->Space to TAB but this converts all of my spaces to tabs, even those of length 1 - which are, for example, spaces between function arguments, not just leading spaces.
In a perfect case scenario I'm trying to achieve formatting style as described in this question, but with typing just spaces and the editor taking care of the rest.
I'm on Notepad++ 6.0, but willing to upgrade if this helps
Let me complete the answer of Ari Okkonen to add a workaround to the problem commented by Sergii Zaskaleta of mixed tabs and spaces at the beginning of the line.
Settings->Preferences->Tab Settings->Tab size: 2 (if not already)
Edit->Blank Operations->Space to TAB (Leading)
Select a block of lines of text with the problem of mixed spaces and tabs. Press [Tab] and [Shift]+[Tab] to add and remove a tab from each line. In the process, the leading spaces had been converted to tabs.
A manual way that seems to work: After having edited the file before saving you may try (Works in Notepad++ v6.8.3):
Settings->Preferences->Tab Settings->Tab size: 2 (if not already)
Edit->Blank Operations->Space to TAB (Leading)

How to turn off Xcode 6 autoindent text files

I use a text file (History.txt) for notes and to keep track of my edits. Xcode 6 is applying the indentation rules to all files, and so manual formatting (using tabs) in my text file is changed when I type a line or copy and paste. For example, typing a semicolon causes a line with leading whitespace to left justify. Prior versions of Xcode didn't do this.
I must have autoindent on for my source code files.
How can I tell Xcode 6 to leave my .txt files alone (no auto indent)?
I had the exact same problem. Didn't find a proper solution, but a workaround is to turn off the auto-indent feature (under Preferences -> Text Editing -> Indentation) for the specific characters that you use a lot in your text files (in my case the colon character was the main culprit) and that you can learn to live without having auto-indent when actually editing code. It's a decent way to get around this problem.

How to create code box without rich text formatting

My question is related to this topic How to copy and paste code without rich text formatting? except its from the opposite viewpoint: I'm creating a document from PowerPoint in which I have code snippets in text boxes. I want to make the document as simple as possible by making the code snippet text boxes easy to copy and paste the code into a terminal to run without editing anything. However, the way I have it right now is that when I copy and paste it keeps the formatting and I have to go though letter by letter to erase the end of line symbols. How should I format this in PowerPoint?
You can get rid of most formatting by copy/pasting from PPT to Notepad and then copy/pasting from there to your terminal program, or if the latter has a Paste Special command, you should be able to paste as plain text, which'd get rid of formatting.
Line/Paragraph breaks are another matter. If the end of line symbols are the only formatting problem when you've pasted the text into a terminal (emulator program, I assume), it sounds as though the terminal's using CR or LF as a line ending, whereas PPT's using CR/LF pairs. It might only be necessary to reconfigure the terminal software to use CR/LF.
It's worth a look at this page on my site, where I explain what line and paragraph ending characters are used by different versions of PowerPoint in different situations.
Paragraph endings and line breaks
http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm
Sorry, my mistake was not realizing that PowerPoint auto formats hyphens and quotation marks to make them stylized, and the terminal was not recognizing the symbols. All I did was type in a quotation mark/hyphen then copying that before I pressed the space bar after it to save the original formatting.

TextMate - Find & Replace Selected Text

In TextMate, does anyone know how you find & replace selected text?
Is this what you're looking for? http://manual.macromates.com/en/working_with_text
4.5.2 Find Clipboard
Two useful key equivalents are ⌘E and
⌘G. The first copies the selection to
the shared find clipboard. This works
in the majority of applications and
allows you to find the next occurrence
of that string by then pressing ⌘G.
The find clipboard works across
applications so whether in Safari,
TextEdit, Mail, TextMate, Terminal,
Console, or similar, one can copy the
selected text to the find clipboard,
switch application and use ⌘G to find
that string.
In addition TextMate offers ⇧⌘E to
copy the selection to the replace
clipboard. This is often useful to
save a trip to the find dialog, for
example if you want to replace
newlines with the pipe character (|)
for a list of items, select a newline,
press ⌘E to use that as the find
string. Now type a |, select it and
press ⇧⌘E so that it is copied to the
replace clipboard.
The next step is then to either press
⌃⌘F to perform the replacement in the
entire document, or select the range
in which you want the replacement to
occur and use ⌃⇧⌘F instead.

Resources