Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
While writing a simple ASCII text document? –  terdon Jun 16 at 13:33
    
yes, for a simple text doccument @terdon. –  Scotia 웃 Jun 16 at 13:35
    
Use the Character Map to get the character and copy it to gedit. –  muru Jun 16 at 13:35
    
how can I use the character map in gedit? @muru –  Scotia 웃 Jun 16 at 13:39
    
can the title of the question be changed to something better. It feels like "Writing power"(something like "mental power") of x(xorg maybe) in gedit ?!?! It confused me at first. –  Registered User Jun 16 at 14:18
show 3 more comments

6 Answers 6

up vote 11 down vote accepted

There is a character map plugin in Gedit, enable it. 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 sidebar 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 there - 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

share|improve this answer
    
For some reason ,1 and 2 are found elsewhere. –  Registered User Jun 16 at 14:15
    
@RegisteredUser Where 'elsewhere'? And how about 3? –  Parto Jun 16 at 14:17
    
I have enabled the character map plug-in. But how can I open it in Gedit?? @parto –  Scotia 웃 Jun 16 at 14:19
    
1,2 and 3 are in latin-1 supplement –  Registered User Jun 16 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 at 14:21
show 5 more comments

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.

share|improve this answer
1  
Nice answer. Just a note, not just ASCII, Any flat text (by default gedit uses Unicode). Could add how to type them or mention a reference for that?. BTW, not all font provide them. I think only 2,3 was in older Unicode which are supported by most fonts –  Sneetsher Jun 16 at 13:55
    
@Sneetsher I have mentioned reference.That's quite good documentation. –  Registered User Jun 16 at 14:06
8  
That's not ASCII. –  gerrit Jun 16 at 14:37
    
@gerrit what's not ASCII? –  Registered User Jun 16 at 14:39
1  
@RegisteredUser: actually, gedit saves in UTF-8 by default (or maybe it depends from the LANG environment variable). The fact that if you don't use characters above 127 you get an ASCII document is a byproduct of how UTF-8 has been designed. –  Matteo Italia Jun 17 at 8:47
show 2 more comments

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.

share|improve this answer
    
there is a lot of character! How can I find out the mathematical characters?? –  Scotia 웃 Jun 16 at 14:08
    
There's a find option. Use it two search. I searched for 'two' and got to the character in a couple of tries. –  muru Jun 16 at 14:33
    
@Scotia웃 I forgot to ping you. –  muru Jun 16 at 14:40
add comment

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.

share|improve this answer
    
It is possible in Unicode text documents. –  gerrit Jun 16 at 14:39
add comment

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
share|improve this answer
    
I always thought this was only for some keyboard layouts. –  Léo Lam Jun 19 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 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 at 18:20
add comment

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.

share|improve this answer
    
No, it's not happening in gedit! –  Scotia 웃 Jun 21 at 4:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.