How to get spaces instead of tabs in eclipse - c++

After doing a little research, I found out that eclipse hides its settings in multiple levels. So, I think, I got all the levels covered here.
Here I have set eclipse to insert spaces instead of tabs. And eclipse even acknowledges there that I have indeed set it up to insert 4 spaces instead of a tab (See the text under Tabulators: it says, "The current indentation size is 4, using spaces").
Then for the general text editor, I have also set it up to insert spaces instead of the tabs.
And eclipse couldn't have gotten things more wrong even if it had tried!
Unfortunately, despite all those settings, when I press tab, eclipse inserts 2 spaces. Then, I press tab again, and it inserts 2 spaces. Why 2 spaces? Are there still more hidden settings somewhere?
Anyways, this broken system works a bit, until I have one level more of indentation, for example, for a for-loop or an if-block. If I press, tab again, instead of adding 2 more spaces, it converts the 6 spaces into a tab.
And a tab which is not even 4 spaces wide, but instead a tab which looks like a 6- or 8-spaces wide tab.
Ctrl + I also adds tabs, not spaces.
The formatter is also setup as #Neuron suggested in his answer.
So, where else is eclipse hiding more settings?

I fixed it by going to..
Window ⟶ Preferences ⟶ C/C++ ⟶ Code Style ⟶ Formatter
There you need to edit the currently set profile. Click "Edit..." (top right-ish). Now go to Indentation (already open) ⟶ General Settings ⟶ Tab Policy and change this from "Tabs only" to "Spaces only".
If you still have the default profile, give your profile a new name.
Why is this so weird and convoluted? I don't know.

Related

how to add tab character into test string section of regex101.com

I am using regex101.com to learn regex.
There will be cases where I want to insert a Tab character within the TEST STRING field of regex101.com.
However, when I have the TEST STRING field selected and press the tab key on my keyboard, it doesn't enter the tab character within the TEST STRING field, but rather it just moves me on to the next selectable feature within the browser page.
I note I have done a bit of googling but so far haven't been able to find the answer to how to add a tab character within the TEST STRING field. Although I know for sure it is possible to do this given that I have seen a few videos where the presenter successfully adds a tab character into the field.
I note that I am using Windows 10 and my browser is Google Chrome.
Would greatly appreciate if anyone could provide an answer to this.
Appears regex101 can enable the tab key to be translated by the editors
instead of being pass-through to the system where it changes focus to the
next control in the tab order.
Just uncheck the box in Settings .
Apparently preference gets saved in your browser session cookies.
Typing a Tab into a text editor and copy-pasting (Ctrl + c / Ctrl + v) it into the browser form is an easy solution. Just make sure your editor is not configured to auto-replace tabs with spaces.
Another way would be using a keyboard combination to enter the ASCII or Unicode character code (see this superuser post). For Windows, that should be Alt+ 0 + 9 (Note: apparently the numbers need to be entered on the numpad).
Finally, depending on the browser you use, there might be browser extensions that facilitate what you want. There used to be one called Tabinta for Firefox and one for Chrome called chrome-textarea-formatter, but I believe neither of them is still maintained.

Is there any way to reindent lines in Swift Playgrounds 4?

Been playing around writing SwiftUI apps on Swift Playgrounds 4 and it automatically indents lines properly as you write them, but I don’t see a method for reindenting all the lines in a selection or in a file.
Obviously when you’re writing SwiftUI you often embed or un-embed elements in stacks, navigation views, and other blocks so reindenting is a frequent need to keep code readable.
Seems you have to delete and reinsert a line break on each line to automatically reindent the lines or manually insert a tab on each line one at a time. You can’t even select several lines at once at press tab to indent them all at once, it just overwrites the selection with the tab.
Is there really no quick way to reindent lines in Swift Playgrounds 4?
Ohh if you hold down the ⌘ cmd key it shows all the keyboard shortcuts.
Re-indenting is ^ control + I
Not sure how you’d do this if you didn’t happen to have a hardware keyboard though…

How to turn on indent structure lines in VS2017?

I accidently turned them off somehow. But I cannot find a hotkey or setting to turn them on again.
It's in Tools + Options, Text Editor, last checkbox.

How to display an ampersand in a Windows system tray prompt?

I'm programming using C++ and WinAPIs. I've added a system tray icon using Shell_NotifyIcon(NIM_ADD, ...) API. That icon also has an associated user prompt that contains an ampersand symbol in it, something like this, "View & Copy." But what a user sees though when the prompt pops up, is "View Copy". I tried doubling the ampersand, like so "View && Copy" but that didn't help.
Does anyone have any idea how to display an ampersand in a Windows tray prompt?
It's not a matter of escaping the ampersand - Windows by design will strip any ampersands from tooltip text, for a generally good reason:
Many applications create toolbars containing tools that correspond to
menu commands. For such tools, it is convenient for the tooltip
control to display the same text as the corresponding menu item. The
system automatically strips the ampersand (&) accelerator characters
from all strings passed to a tooltip control, and terminates the
string at the first tab character (\t), unless the control has the
TTS_NOPREFIX style.
As you can see, the answer is very easy: you just need to add TTS_NOPREFIX to the tooltip class and you'll be set.
Apparently, ampersands require double-escaping, like this &&&.
I'm not sure why but it seems to work.
My source: this link.

How to remove tab indent from several lines in IDLE?

If you want to indent several lines in Python IDLE you just mark the lines and hit Tab. But what if you want to remove the indent from several lines? Shift+Tab does not work for that in IDLE.
If you're using IDLE, you can use Ctrl+] to indent and Ctrl+[ to unindent.
If you're using IDLE, and the Norwegian keyboard makes Ctrl-[ a problem, you can change the key.
Go Options->Configure IDLE.
Click the Keys tab.
If necessary, click Save as New Custom Key Set.
With your custom key set, find "dedent-region" in the list.
Click Get New Keys for Selection.
etc
I tried putting in shift-Tab and that worked nicely.
Depends on your editor.
Have you tried Shift+Tab?
in pythonwin,
SHIFT + TAB works
For IDLE, select the lines, then open the "Format" menu. (Between "Edit" and "Run" if you're having trouble finding it.) This will also give you the keyboard shortcut, for me it turned out that dedent shortcut was "Ctrl+["
Shift-Tab
Ctrl-Tab
< key
depends on your editor.
In Jupyter Notebook,
SHIFT+ TAB(to move left) and TAB(to move right) movement is perfectly working.
By default, IDLE has it on Shift-Left Bracket. However, if you want, you can customise it to be Shift-Tab by clicking Options --> Configure IDLE --> Keys --> Use a Custom Key Set --> dedent-region --> Get New Keys for Selection
Then you can choose whatever combination you want. (Don't forget to click apply otherwise all the settings would not get affected.)