A little confused at the purpose of the "tab size" in GitHub's markdown editor. When changing the value in the dropdown, it seems to have an effect in the "Edit File" tab but not the "Preview" tab. Nor does it have an effect after saving.
Bottom line, I'd like my tab size to be 2 when displayed in my repository readme, instead of 8 which makes the markup seem disorganized.
Thanks for your help.
You need to manually convert all the existing tabs to spaces in the document.
Changing the setting in your editor/IDE or on GitHub (to use spaces) does not change any existing text in the document. It only affects any new text you add to the document. If the existing content includes tab characters, you need to convert those to spaces for consistency. While you would need to manually change each instance on GitHub, your local editor/IDE should have a function to do that document wide from a single command (usually called something like "convert tabs to spaces").
By way of explanation, when a tab is inserted in a document, all that happens is a tab character is inserted. No information is included indicating how wide that tab character should be. Each document viewer will have its own setting indicating how wide a tab character should be and if those settings do not match, then the document will display differently in each context. For example, the GitHub editor can be configured to be different that the default. However, the rendered preview does not have any settings so you only get the default tab wide (8 chars on GitHub).
For that reason, most editors/IDEs include a setting to insert spaces when you type the tab key. That insures that every tab is exactly the same width across all viewers anywhere. However, the "spaces" feature of editors works by intercepting the press of the tab key on your keyboard and replacing the tab with the set number of spaces. Therefore, actual space characters get inserted into your document and there are no tab characters (the editor hides this by also intercepting backspace key presses). The important thing to note is that this feature works by intercepting and altering key presses on the keyboard. Therefore, it has no effect on text already in the document. Which is why you need to convert the existing text. Fortunately, the "convert tabs to spaces" feature of most editors/IDEs will use the tabs/spaces settings when doing the conversion, so running that command once should fix the entire document as long as your settings are configured properly.
Most editors/IDEs also have a "show whitespace" (or "view whitespace)" feature, which can be used to confirm the conversion was done properly. When "show whitespace" is turned on, tabs display as an arrow and spaces as dots (usually a lighter gray than the surrounding text). If you have converted your entire document. you should see no tab arrows anywhere, only dots for spaces. Once you are satisfied that no tabs exist, you can then turn "show whitespace" off. Unfortuntely, GitHub's online editor does not offer this feature, so you'll need to use your local editor.
Related
I'm able to highlight text but I'd like to use custom highlight colors. Even if I define custom colors, Word seems to use one of the colors in the default palette that it thinks is closest.
myRange.font.highlightColor = "#ffcc00"; // Should be orange. Comes out red
That color should come out orange but it comes out red.
Any ideas?
Word does not support custom highlight colors - only the traditionl, basic sixteen colors. This is a limitation of the Word application, not the Office JS APIs.
It would be possible to apply custom colors using Shading, however (as in borders and shading).
Here's a work-around to the problem of defining custom highlight colors which I discovered quite some time ago ..
If you paste in highlighted text copied from an application from outside of Word (i.e., highlighted text from an AOL email let's say), you can then:
Use the insertion bar to select and highlight an area of the text you just pasted in
Press the FORMAT PAINTER tool to copy the formatting of the area you've selected. The pointer changes to a PAINTBRUSH icon (with an insertion bar attached)
Move the PAINTBRUSH to the existing Word text that you want to highlight using the new color
Press and hold the mouse button (usually the left button) while selecting the specific text
Release the mouse button to apply the new highlighting and formatting
The applied highlighting will also include any other existing formatting; so you MAY have to change the font or adjust some other feature (i.e., turn on/off bold, italics, underline, etc.) But this is easily accomplished. The point is that you can now have ANY color highlighting that you prefer – this hack absolutely DOES work!
Here's, one last thing – when you save the document (by clicking the OFFICE BUTTON in the upper left corner), I would advise that you first select WORD OPTIONS, then SAVE and check the box next to "Embed fonts in the file" under "Preserve fidelity when sharing this document" (I always uncheck the other two boxes). This is to ensure that before you export or print the document, you may be sure that all the fonts and features have been saved within it.
And for the record, this technique is NOT shading.
The highlighting comes from actual HIGHLIGHTED TEXT copied from a document or application from OUTSIDE of Word. So it has nothing whatsoever to do with Word's shading feature. I've even copied highlighted text from non-dedicated word processing applications, and then pasted the text into Word – where it is then available to apply the copied highlighting to text within the existing Word document.
If you think about it – the fact that Word 2007 permits you to define any THEME color you want clearly shows that one should be able to define ANY desired custom HIGHLIGHTING color as well – besides just the 15 basic colors (and excluding the "no color"). And this work-around proves that this is so. The problem is that the Word application itself does not permit you to accomplish this directly.
In Eclipse Mars and later, I want tab characters that are already present in the text to display as 8 spaces, but whenever I press the tab key I want to insert 2 real space characters. Is it possible to set eclipse to display embedded tab chars as one indent setting and yet insert spaces on a different indent setting?
In general, no. The only available generic and common settings are in Preferences > General > Text Editor, and you have:
Displayed tab width which allows to set the number of spaces used to render tabs (if you indent with tabs), or the number of spaces to insert on tab (if you indent with spaces)
insert spaces for tabs to decide whether to indent with tabs or spaces.
But some specific editors (HTML, XML, CSS...) allows to somehow override this settings and give more control on tabs. You can usually find them in Preferences, then searching for tab or formatter. Those settings are specific to one kind of editor and not propagated across all editors. But maybe that can be enough for your use-case.
If you want something more generic, feel free to open an enhancement request to bugs.eclipse.org.
I downloaded some code from the Internet, and the four-space indentation is bugging the crap out of me. I tried to do a find and replace for "<4 spaces>" and replace it with "\t", but that just replaced all sets of spaces with the string "\t". How would I put a tab in the "replace" box?
Open Window->Preferences from menu bar.
Select Text Editors from tree menu.
Uncheck Insert spaces for tabs.
After that, run Format menu from context menu and save the file:
I figured it out. I just check the box that says "use regular expressions", then use \t.
In answer to the second half of your question:
The reason why people like spaces more than tabs is consistency. If you have your editor set to show tabs as 4 spaces wide, and I have my editor set to show tabs as 8 spaces wide, the code we're writing will look different to each of us. That's okay until our mutual coworker forgets that we're using tabs and starts spacing his lines using 4 spaces. Now his code looks fine to you, but all the indentation is off to me.
Also, what happens when our work decides that lines should be 80 characters long, or 120 characters long? You'll happily code with 4 space tabs, and when it gets to my editor, I suddenly see some of your lines as too long.
Generally, it doesn't matter whether you use spaces or tabs, as long as you (and every person who works on your code) agrees on which to use, and how wide a tab character is.
I use 4 spaces everywhere, because it looks the same on every editor, every repository, when cated, and everywhere else.
Kouhei response is in the right track, but you'll need to change the options of the Java formatter if you want the auto formatter to use spaces (in the preferences, look for Java -> Code Style -> Formatter, create a new style from one of the existing one, and choose "always use spaces"). Then, Ctrl + Shift + F will remove the tabs and insert spaces.
To resolve the issue of tab with space in the Eclipse editor:
Menu Window --> Preferences --> Java --> Code style --> Formatter
Click on configure project specific settings.
Choose the project
Check Enable project-specific settings
Click on New
Mention your profile name --> click OK.
The profile page will be popped up
Choose Space only under tab policy label of the indentation tab.
Click apply and the OK.
Use Ctrl + Shift + F to format a Java class which will replace tab with space.
Eclipse Helios for C++ developers
Instead of changing the default text editor, change the Code Style/Edit -> see pictures
I'm using Eclipse + EGit, and every time I make a commit, Egit detect tab chars as changed:
but I don't change anything on that part of the code. Tab chars are tab chars, and are not replaced by whitespaces.
Any idea ?
You may have some auto formatter active, which replaces tabs by blanks or the other way around. This may not really be visible in the editor on first glance, as the editor can display a tab character the same as the respective number of blanks. You may want to store the original file and the edited one separately outside Eclipse to compare them in another editor.
However, you can ignore whitespace changes in the compare view at least. I'm not sure of your version, for me that is a toolbar button in the main toolbar. You can press Ctrl-3 and enter "Ignore" to see, if that command is available for you.
Usually I'd like to edit files with Spaces only.
But when I open files with Tabs, I'd like to see them (for example as arrows ->). With such files I do my edits careful, so not to destroy the original authors coding style -- usually I insert tabs by hand when needed.
So, I want to see Tabs all the time, but using the General, Editors, Text Editors, Show Whitespace Characters option, I get distracted by all the whitespace-dots.
How can I reduce this distraction by Spaces, but at the same time see the Tabs?
Can I change the font color for the visualized whitespaces to a brighter color? currently they are medium gray, but I can not find an option to change that.
Or can I choose different setting for Tabs and for Spaces (and Paragraph signs, for that matter)?
The way I used to have it in my goo' ol' editor would be: Change the background color of Tab to light-yellow (without display the -> for tabs or the dots for Spaces). This makes Tabs wuite visible, without harming my "normal" source visualization. This would be my favorite. I did that by adding the Tab to be a keyword in all languages, and then change the keyword background color to a bright yellow.
According to the Eclipse 3.7M3 New and noteworthy you can customize the Show Whitespace Characters to show only tabs but not spaces.
Unfortunately the stable version of Eclipse 3.7 is expected in 2011 summer but if that feature is a 'must' for you you can try that milestone.