subscripts and superscripts

953 views
Skip to first unread message

kamaraju kusumanchi

unread,
May 31, 2016, 12:47:37 AM5/31/16
to v...@vim.org
For normal editing purposes, I use vim and it works great. But once in
a while, I want to use subscripts and superscripts. For example, while
writing chemical equations I would like to see O with a subscript 2 to
represent the Oxygen molecule. Without using heavy weight stuff such
as Latex, could I somehow make vim/gvim show subscripts and
superscripts?

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

Markus Osterhoff

unread,
May 31, 2016, 1:34:02 AM5/31/16
to vim...@googlegroups.com
* kamaraju kusumanchi <raju.mai...@gmail.com> [160531 06:46]:
> Without using heavy weight stuff such as Latex, could I somehow make
> vim/gvim show subscripts and superscripts?
For single digits and using UTF-8 encoding, this is possible with vim's
digraphs. In insert mode, press
CTRL-K, then the digit, then S (cap S) → ⁰¹²...⁹ for superscripts, or
CTRL-K, then the digit, then s (small s) → ₀₁₂...₉ for subscripts.

Btw., for chemical reactions you might try these nice arrows:
← → ↔ with CTRL-K <- and -> and <>

Use :help digraph or simply :digraphs for more.

Greetings,
mo

--
Markus Osterhoff
http://sci.photos

signature.asc

Jürgen Krämer

unread,
May 31, 2016, 1:35:39 AM5/31/16
to vim...@googlegroups.com

Hi,

kamaraju kusumanchi schrieb am 31.05.2016 um 06:46:
> For normal editing purposes, I use vim and it works great. But once in
> a while, I want to use subscripts and superscripts. For example, while
> writing chemical equations I would like to see O with a subscript 2 to
> represent the Oxygen molecule. Without using heavy weight stuff such
> as Latex, could I somehow make vim/gvim show subscripts and
> superscripts?

Unicode contains subscript and superscript digits. With 'encoding' set
to UTF-8 and an appropriate font you can enter them via Vim's digraph
capabilities. Just press <Ctrl-K>s1 ... <Ctrl-K>s9 for subscript digits
and <Ctrl-K>S1 ... <Ctrl-K>S9 for superscript letters while in insert
mode.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

kamaraju kusumanchi

unread,
Jun 1, 2016, 8:50:23 PM6/1/16
to vim...@googlegroups.com
Thanks mo. It works great and exactly what I need.

raju

kamaraju kusumanchi

unread,
Jun 1, 2016, 8:55:01 PM6/1/16
to vim...@googlegroups.com
On Tue, May 31, 2016 at 1:35 AM, 'Jürgen Krämer' via vim_use
<vim...@googlegroups.com> wrote:
>
>
> Unicode contains subscript and superscript digits. With 'encoding' set
> to UTF-8 and an appropriate font you can enter them via Vim's digraph
> capabilities. Just press <Ctrl-K>s1 ... <Ctrl-K>s9 for subscript digits
> and <Ctrl-K>S1 ... <Ctrl-K>S9 for superscript letters while in insert
> mode.
>

Thanks Jurgen. Is there a typo in your commands? When I enter
a<Ctrl-k>S2 I get a<8e> but a<Ctrl-k>2S works fine and gives a with a
superscript 2.

Jürgen Krämer

unread,
Jun 2, 2016, 2:49:05 AM6/2/16
to vim...@googlegroups.com

Hi,

kamaraju kusumanchi schrieb am 02.06.2016 um 02:54:
> On Tue, May 31, 2016 at 1:35 AM, 'Jürgen Krämer' via vim_use
> <vim...@googlegroups.com> wrote:
>>
>> Unicode contains subscript and superscript digits. With 'encoding' set
>> to UTF-8 and an appropriate font you can enter them via Vim's digraph
>> capabilities. Just press <Ctrl-K>s1 ... <Ctrl-K>s9 for subscript digits
>> and <Ctrl-K>S1 ... <Ctrl-K>S9 for superscript letters while in insert
>> mode.
>>
>
> Thanks Jurgen. Is there a typo in your commands? When I enter
> a<Ctrl-k>S2 I get a<8e> but a<Ctrl-k>2S works fine and gives a with a
> superscript 2.

yes, I accidentally swapped the order of "S"/"s" and the digits. I already
noticed this while testing, but I missed to make the corrections in my mail.
Sorry.

Charles E Campbell

unread,
Jun 2, 2016, 10:31:16 AM6/2/16
to vim...@googlegroups.com
kamaraju kusumanchi wrote:
> For normal editing purposes, I use vim and it works great. But once in
> a while, I want to use subscripts and superscripts. For example, while
> writing chemical equations I would like to see O with a subscript 2 to
> represent the Oxygen molecule. Without using heavy weight stuff such
> as Latex, could I somehow make vim/gvim show subscripts and
> superscripts?
>

With my math plugin (see
http://www.drchip.org/astronaut/vim/index.html#MATH), one may use visual
mode on a digit and press "_" to make it into a subscript and press
"^" to make it into a superscript. Use visual mode to select a
alphameric character and press "&amp;" to make it into a corresponding
Greek character. Use visual mode on a "->" or "<-" and transform it
into a nice Utf-8 arrow.

Chip Campbell

Nikolay Aleksandrovich Pavlov

unread,
Jun 2, 2016, 11:14:09 AM6/2/16
to vim...@googlegroups.com
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

My [translit3][1] plugin contains transsymb-math transliteration
table, so you may use

:Tr3Command tof start transsymb-math
:" or
:let g:tr3_DefaultTranssymb = 'transsymb-math' | " Better put this
in the vimrc
\ts
:"`\ts` is normal-mode command that runs `:Tr3Command tof start`

to make `^3` automatically transformed into `³` as typed. Arrows `<-`
and `->` are also transformed into `←` and `→`. Greek letters are also
supported: e.g. `|a` is `α`. `:Tr3Command add -> → to transsymb-math`
can add what is missing.

With default settings though `%` temporary disables/enables
transliteration as you type and `@` breaks sequence (`^@3` results in
`^3`, this is needed to prevent some transformations like “shema” →
“шема” (error), while needed “s@hema” → “схема” (“scheme” in
Russian)), so you may need to choose another key or disable these
features.

[1]: https://bitbucket.org/ZyX_I/translit3

kamaraju kusumanchi

unread,
Jun 2, 2016, 10:48:31 PM6/2/16
to vim...@googlegroups.com
Thanks Chip. The screenshot on the plugin page looks great.Will try it out.

sinbad

unread,
Jun 14, 2016, 3:03:08 AM6/14/16
to vim_use
On Tuesday, May 31, 2016 at 11:05:39 AM UTC+5:30, jott...@googlemail.com wrote:
> Unicode contains subscript and superscript digits. With 'encoding' set
> to UTF-8 and an appropriate font you can enter them via Vim's digraph
> capabilities. Just press <Ctrl-K>s1 ... <Ctrl-K>s9 for subscript digits
> and <Ctrl-K>S1 ... <Ctrl-K>S9 for superscript letters while in insert
> mode.

Does this work in textmode ? my digraph output is as follows, i think the font doesn't support. As encoding is utf-8. what font in text mode should
i use to see the proper digraphs ?

:digraphs
NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5 AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^@ 10 VT ^K 11 FF ^L 12 CR ^M 13 SO ^N 14 SI ^O 15
DL ^P 16 D1 ^Q 17 D2 ^R 18 D3 ^S 19 D4 ^T 20 NK ^U 21 SY ^V 22 EB ^W 23 CN ^X 24 EM ^Y 25 SB ^Z 26 EC ^[ 27 FS ^\ 28 GS ^] 29 RS ^^ 30 US ^_ 31
SP 32 Nb # 35 DO $ 36 At @ 64 <( [ 91 // \ 92 )> ] 93 '> ^ 94 '! ` 96 (! { 123 !! | 124 !) } 125 '? ~ 126 DT ^? 127 PA <80> 128 HO <81> 129
BH <82> 130 NH <83> 131 IN <84> 132 NL <85> 133 SA <86> 134 ES <87> 135 HS <88> 136 HJ <89> 137 VS <8a> 138 PD <8b> 139 PU <8c> 140 RI <8d> 141 S2 <8e> 142 S3 <8f> 143 DC <90> 144 P1 <91> 145
P2 <92> 146 TS <93> 147 CC <94> 148 MW <95> 149 SG <96> 150 EG <97> 151 SS <98> 152 GC <99> 153 SC <9a> 154 CI <9b> 155 ST <9c> 156 OC <9d> 157 PM <9e> 158 AC <9f> 159 NS ▒ 160 !I ▒ 161
Ct ▒ 162 Pd ▒ 163 Cu ▒ 164 Ye ▒ 165 BB ▒ 166 SE ▒ 167 ': ▒ 168 Co ▒ 169 -a ▒ 170 << ▒ 171 NO ▒ 172 -- ▒ 173 Rg ▒ 174 'm ▒ 175 DG ▒ 176 +- ▒ 177
2S ▒ 178 3S ▒ 179 '' ▒ 180 My ▒ 181 PI ▒ 182 .M ▒ 183 ', ▒ 184 1S ▒ 185 -o ▒ 186 >> ▒ 187 14 ▒ 188 12 ▒ 189 34 ▒ 190 ?I ▒ 191 A! ▒ 192 A' ▒ 193
A> ▒ 194 A? ▒ 195 A: ▒ 196 AA ▒ 197 AE ▒ 198 C, ▒ 199 E! ▒ 200 E' ▒ 201 E> ▒ 202 E: ▒ 203 I! ▒ 204 I' ▒ 205 I> ▒ 206 I: ▒ 207 D- ▒ 208 N? ▒ 209
O! ▒ 210 O' ▒ 211 O> ▒ 212 O? ▒ 213 O: ▒
Reply all
Reply to author
Forward
0 new messages