How to write superscript / upper index in Visual Studio? - visual-studio-2012

It is possible, but I don't know how is it done.

Use the Windows Charmap.exe applet. In the Font combobox select a font that has a lot of glyphs, Arial Unicode MS is a very good choice. Tick the Advanced view checkbox and type "super" in the Search box. The grid will show all superscript glyphs, select and copy from that and paste into your source code.
Or copy/paste one of these: ¹²³⁴⁵⁶⁷⁸⁹⁰
Subscript characters: ₀₁₂₃₄₅₆₇₈₉

Adding more details to complement #HansPassant's answer. Other frequently used sets which can be used as is by copy/paste:
Superscript small case letters: ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ
Subscript small case letters: ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ
If you're wondering why few letters are missing in above series then please read below posts:
Where are the other letters in this Unicode block?
Why does the unicode Superscripts and Subscripts block not contain simple sequences of all letters?
Why is there no character for "superscript q" in Unicode?

Since there is a tag visual-studio-2012, I assume you are running Windows. There is a great opensource program called WinCompose, which allows to use easy-to-remember and intuitive shortcuts for a huge amount of Unicode symbols, including numerical super- and subscripts. Every shortcut is invoked via a Meta key (e.g. Right Alt), for example:
Meta + ^ + 1 gives ¹;
Meta + _ + 9 gives ₉.
WinCompose also supports search, can be run in background, and eliminates tedious procedure of calling Character Map with subsequent copy-pasting or remembering the Unicode charsets (but the latter are also listed):
P. S. I'm not affiliated with this software by any means. Just a happy user.

One more way for WPF users,
<TextBlock >
<Run>x</Run>
<Run FontSize="8" BaselineAlignment="TextTop" >2</Run>
</TextBlock>
Change BaselineAlignment to TextBottom if you want to use as subscript.

In VsCode download the extension "Fast Unicode Math Characters".
The hotkeys for ₂ is \_2.
The hotkeys for ² is \^2.

Looks like there are some simple tags that you can use to make any text superscript/subscript. The superscript tag is <sup> and the subscript tag is <sub>.
https://www.w3schools.com/tags/tag_sup.asp

use (Ctrl + Shift + P) command to apply superscript and subscript in Visual Studio.

This is how usually I tend to do it on Mac.
In the VS code, hit (Control + Command + Space) to bring up the Character selector and search for 'superscript' in the search box.
Click on required superscript and add it. And here is the result. Screenshot are from the VS code only.
This approach should work across most of the apps in the Mac. Tested in MacOS 12.5. (Monterey)

There are several solutions. Personally, I simply formaat the label text in Word, use a screen capture and save it as an image that I use with a label.

Related

How to insert an "—" direclty from my Keyboard without numberpad?

I have searched all corners of the internet, yet to find an answer to my simple question:
How to place, directly from keyboard input, the Em-Dash "—" character onto a code editor such as Notepad++ or Dreamweaver using modern notebooks (such as a dell xps 13" 2015, win10 64bit) without:
any extended keyboard numbpad, obviously;
any third party automation scripting softwares;
any charactermap insertion tools such as windows charactermap
How? Thanks!
I imagine you're asking about how to do it in Windows here.
I assume you know how you'd do it if you had a numeric keypad (Alt + 0151 if as it seems you are on the 1252 code page).
See also Insert Unicode characters via the keyboard? , in order to use the unicode value (Alt + +2014) .
This is an at least related question: How to emulate numpad on a PC laptop?
Possible solutions:
Most notebooks do have an hidden "numpad", accessible through the Fn key (see for example https://www.dummies.com/computers/pcs/the-hidden-numeric-keypad-on-your-laptop/ ).
I couldn't find out for sure if the Dell XPS 13 specifically does, but it is very likely.
This Me and My Dell manual (Using numeric keypad on a laptop) seems to explain its usage for all Dell laptops.
Use copy and paste (copy the character from some place and paste in the editor). A clipboard manager might help you if you choose to go this way.
You might also use some third-party software to have that character emitted when you press a key or shortcut, but I guess that is included in your "third party automation scripting softwares" prescription.
Use the unicode combination! I now found out that with that one you can use indifferently both numbers from the keypad and normal ones !
Unfortunately it still requires the numpad's "plus" (add) key, so you need to be able to type at least that.
See Insert Unicode characters via the keyboard? or https://en.wikipedia.org/wiki/Unicode_input to learn how to enable the combination, if it is not already enabled.
If there indeed exist laptops with no numeric keypad support unfortunately the Windows developers didn't fully anticipate for that; it probably wouldn't take much and wouldn't have negative repercussions for Windows to support the insertion via the normal numeric keys (or the normal + for the Unicode combination), but for now it's not supported (as far as I know).
It would be a bad mistake on the part of the laptops' developers to not include any way to type the numpad keys, though, as they are required by many programs.

Special characters on MFC dialog form

I can see special characters ąęį when I do form design on static text label:
These character are changed while running:
If I set these characters in programming way I have:
How can I ensure that the correct characters are displayed instead of question marks as shown in the screenshot above?
UPD:
My project is Multi-Byte. I found that in another computer I can see special characters. Why?
You need to use Unicode character set for this to work correctly, and my guess is that you're using MBCS character set now.
You could change it in the project properties. Refer to this screenshot:
Visual studio editor is fully Unicode, meaning it could display such special characters as you type when you're designing the dialog. However, if your application is not built with Unicode support, it won't be able to display thsoe characters when it runs. Thich is why you see the ??? replacing the Unicode text when you run the application.
If you get different results on different computers this is obviously due to differences in system settings.
The setting that controls this is called "Language for non-Unicode programs", and can be found under Control Panel, Language, Change date, time or number formats. Unfortunately it's a global setting (ie cannot be set per application or programmatically) and requires a re-boot.
Consider making your application Unicode, if possible (and meaningful cost- or effort-wise).

Creating your own LaTeX keyboard layout : 1 key = multiple caracters

I've been looking for the answer for quite some time now. This is a project I have but I can't manage to find a way to do it. The main idea would be to plug an additional keyboard on my computer that write multiple letters by hitting only one key. For example, instead of writing down a (when I hit the a key), it would write \textbf{ (for example).
I already manage to find the keyboard layout file under Linux and to switch the a and b keys, but I cannot find a way to print multiple characters.
I know it exist editors (like Texmaker or Kile) that have auto-completion, but I'm most of the time working in project in groups and therefore we use writelatex.com which does not propose auto-completion in it's free user pack ! Besides, I'm doing that for my personal interest.
Thanks a lot.
Have a look at autokey. It can assign phrases to hotkeys. It requires X11.
Another option might be to use a powerful text editor like vim or emacs which both have features like this, and then copy/paste the text into writelatex.com.
Some browsers have add-ons that allow you to edit the contents of a text field on a web page with a chosen text editor.
Edit: In Xorg you can use the X KeyBoard extension to e.g. change the meaning of individual keys. While you can configure the keyboard to generate (multibyte) unicode characters, you cannot assign arbitraty character strings to one key, to the best of my knowledge.

AutoHotkey diacrictics mappings not working correctly with Vim

I've been using some mappings in Vim to avoid having to switch keyboard layouts to type in diacritics in my language (Croatian). However, now I wanted to move these mappings "up" so that they're available globally. I tried using AutoHotkey for this. Here are the mappings I wrote
#CommentFlag //
!;::Send {U+010D} // č
!'::Send {U+0107} // ć
!]::Send {U+0111} // đ
![::Send {U+0161} // š
!\::Send {U+017E} // ž
These work great in every application I've tried (browsers, notepad, MS Word), but don't work in Vim, which is pretty annoying as I do most of my typing there. More specifically, only 'š' and 'ž' work as expected, while both Alt-; and Alt-' give me a 'c' (instead of 'č' and 'ć'), and Alt-] gives a 'd' (instead of a 'đ').
I'm using AutoHotkey_L (though I had the same results with the "regular" AHK), Vim 7.3 (trying this in gVim; it doesn't work in the terminal version either (in a slightly different way) but I don't really care about that) on Win8.
I can give more info on the Vim version, but it's basically one of those windows binaries from vim.org. Things I guess might be important is that it has +multi_byte, and I've been using Unicode in it with no problems whatsoever.
Update:
As per Ingo's suggestion below, I've tried using IfWinNotActive to not have the mappings present in Vim and continue to use my old ones there. Here's one example I've tried
SetTitleMatchMode 2
IfWinNotActive GVIM
{
#CommentFlag //
!;::Send {U+010D} // č
!'::Send {U+0107} // ć
!]::Send {U+0111} // đ
![::Send {U+0161} // š
!\::Send {U+017E} // ž
}
I've also tried many other variations with the Vim window class (using ahk_class), with #IfWindowNotActive etc., but to no avail... The mappings are still there in Vim. Btw, the window title always contains the string "GVIM", and AHK sees that as I've confirmed with WinGetTitle.
I don't have a solution, but a workaround: When I faced with the same issue, I decided to emulate Vim's digraphs globally (also using AutoHotkey), and just except Vim (and applications like Remote Desktop) from that feature (so that the full range can still be used there; my script only supports a subset). You can find my implementation here.
You can also edit a keyboard layout itself, using Microsoft Keyboard Layout Creator.
For example, the English one that you use: choose combination of some character and some function key (Ctrl or Right-Alt, with or without Shift − e.g. for Caps).
Here’s how it looks:
I find the Apple International US layout very good for this purpose, having all the accents available using dead keys, so I've implemented it with Microsoft Keyboard Layout creator like stansult suggested.
Then I came up with the problem of having only one "Alt" key usable, so I ended up remapping my Windows and Alt keys using ScanCodemap. This is a viable solution if you don't use the Windows key that often. One caveat of this method is, that you'll have to use Win+Tab instead of Alt+Tab from now on to switch between windows, it takes a couple of days to get used to that.
Windows Registry Editor Version 5.00
; 0x003a001d: Caps Lock (0x3a) -> Left Ctrl (0x1d)
; 0x0038e038: Left Alt (0xe05c) -> Right Alt (0x38)
; 0xe05b0038: Left Windows (0xe05b) -> Left Alt (0x38)
; 0xe05c0038: Right Windows (0xe05c) -> Left Alt (0x38)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,1d,00,3a,00,38,e0,38,00,38,00,5b,e0,38,00,5c,e0,00,00,00,00

apostrophes changes when I copy and paste

When I cut and paste apostrophes between programs (ie. notepad2, notepad++, hiedisql, word, etc etc) and wysiwyg's, and source codes my apostrophe is changing a little. It looks different and it behaves differently depending on the copy source and paste source.
Is this normal? Is there any way to make sure everything renders the apostrophe the same way? is this a windows thing?
I feel like this is a new thing, but maybe it has always been like this.
Do you mean that ’ -- should look like: -- turns into ' ??
If so, your editor program is "helpfully" changing a non-Ascii right apostrophe into the only apostrophe available in Ascii, the "straight" apostrophe: ' (Or vice-versa.)
The right and left apostrophes are defined in Unicode and ISO 8859 character sets, but not Ascii.
Solution Check the docs for your editors to see if you can turn off the behavior. It may not be possible depending on the specific editing software and its version.
Added Even this editor in Stack Overflow caused me some problems: I entered the Unicode right apostrophe, and it looked fine in the editor. But the preview window (and the display of my answer) shows the apostrophe as being a "straight" apostrophe: it appears that the font used by Chrome for displaying and previewing the answer shows a straight apostrophe instead of a right one. So I added a graphic for the right apostrophe.
Blog post about the problem
For writing software, SQL, etc, you should stick to the straight apostrophe. Editors should not convert the straight apostrophe to the right apostrophe. The issues of single quotes (apostrophes) and straight quotes vs opening and closing quotes is a primary difference between a document editor and a code (software) editor. If your editor changes apostrophes and quotes for you, it can cause a lot of problems in your software. You can usually turn off the behavior of "smart quotes" or similar.

Resources