14

In gedit, how can I write x^2 without using ^? Where 2 will be the superscript of x.

opu 웃
  • 2,137
  • 11
  • 29
  • 42

6 Answers6

14

A Character Map plugin is available for gEdit. Enable the plugin in the Preferences. Enable the Side Pane in the View menu. Click on the Character Map icon at the bottom of the Side Pane, then choose "Common" and you will find the superscript 4 (even though it looks like am missing superscript 1-3). Below that are the subscripts and other special characters.

To use a certain character, just drag it from the character map on the Side Pane to the document. You can then copy-paste it in the right position.

From a question in the comments below:
After enabling the character map plugin, you can open/view the characters by click the icon that looks like a key with an "a" on it on the bottom left corner.

In my screenshot below, there are three icons in the Side Pane: The first is the documents icon to view all open documents, the second is the file browser for the file browser plugin and the third is the Character Map plugin.

Check screenshot below:

enter image description here

Zanna
  • 70,465
Parto
  • 15,325
  • 24
  • 86
  • 117
  • 1
    For some reason ,1 and 2 are found elsewhere. – Registered User Jun 16 '14 at 14:15
  • @RegisteredUser Where 'elsewhere'? And how about 3? – Parto Jun 16 '14 at 14:17
  • I have enabled the character map plug-in. But how can I open it in Gedit?? @parto – opu 웃 Jun 16 '14 at 14:19
  • 1
    1,2 and 3 are in latin-1 supplement – Registered User Jun 16 '14 at 14:21
  • At the bottom left, click the icon that looks like a key with an 'a' on it. Then at the top section, scroll till you find the common package and then look for the Superscripts therein. – Parto Jun 16 '14 at 14:21
  • @RegisteredUser I don't have a Latin-1 supplement section, just Latin. – Parto Jun 16 '14 at 14:23
  • I checked in character map, maybe the plugin contains different section names? – Registered User Jun 16 '14 at 14:25
  • @RegisteredUser Okay. Will look for it later in the plugin. – Parto Jun 16 '14 at 14:32
  • The plugin's character map is added to the side pane, so make sure that's visible. It's organized by script, not by block (the standalone Character Map lets you switch), so the superscript digits are all in Common, though separated. ¹ ² and ³ are in the early U+00Bx range and appear near the top, with the others further down in U+207x; you'll probably need to scroll for a bit to find them, while watching the status bar. – deltab Jun 17 '14 at 05:03
  • 1
    One thing you omitted was how to get that plugin. You need to install gedit-plugins; you can do this from Ubuntu Software Centre, Synaptic Package Manager, or via the CLI with sudo apt install gedit-plugins (prior to 14.04 use apt-get instead of apt). – Paddy Landau Jun 24 '14 at 16:23
12

As terdon said, an ASCII Text file means ONLY text, no formatting as in Libreoffice writer files.

But in the specific case , you can use the unicode characters that refer to superscripted 0-9 and subscripted 0-9.

Here are they ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉

A document on how to tpye special characters is available offline in Ubuntu Desktop Guide(search for Enter special characters) as well as online here on gnome.org.

Registered User
  • 9,631
  • 14
  • 53
  • 85
7

gedit can and does support Unicode files. Use the Character Map to obtain Unicode characters. The Character Map isn't part of gedit, but is a separate application. Just click the Dash button in the corner and type 'Character Map'. Or press Alt+F2 and type charmap and press enter.

muru
  • 197,895
  • 55
  • 485
  • 740
6

As mentioned by other answers, you can use unicode characters to do so.

The nice bit is that if you write x^2 the characters ^2 will convert into ² As it is done at quite low level (Xlib), it works on almost all applications.

The rule lives at /usr/share/X11/locale/en_US.UTF-8/Compose (other UTF-8 locales also include this file), iso8859-* locales also have them for characters they can print

 <dead_circumflex> <2>              : "²"   twosuperior # SUPERSCRIPT TWO
Ángel
  • 386
  • 1
  • 7
  • I always thought this was only for some keyboard layouts. – Léo Lam Jun 19 '14 at 20:45
  • Léo-Lam, you just need a dead_circumflex key. That is a ^ key that when pressed once does nothing, but pressing ^ and then arenders â. Of course if your default layout doesn't contain that you could "add" it with xmodmap – Ángel Jul 13 '14 at 17:55
  • I understand that; I just thought that the dead keys existed in some keyboard layouts only: looks like they are pretty common, since the English keyboard layout has dead keys. – Léo Lam Jul 13 '14 at 18:20
3

If you have a dead key with ^, you can press it and then the number you want. It would render the number in superscript without the circumflex.

Pedro
  • 31
  • 1
2

You can't. Simple ASCII text documents don't support any kind of formatting. No italics, no bold, no superscript, no subscript no nothing. If you do add such formatting to your file, it will no longer be a simple text document.

So, if you need that kind of functionality, use a format that supports it such as rtf or odt or (shudder) doc.

terdon
  • 100,812