11

I want to type the subscript i as follows:

subsript i

What I have tried:

  1. I got to know how to type numerial subscripts, by following this documentation.
    <ctrl-k>[digit]s
  2. I search the local help doc (absolutely the same as the above) by :h digraphs and find only those for numbers also.

    help doc

    No more no less.

  3. I have found a plugin for doing this and got to know the author's implementation.

    _i                       <char-0x1D62> " ᵢ
    

I raise this question for asking if I can type the alphabetic subscripts without plugins (which also means don't use the daunting commands as <char-0x1D62>). I need commands like <ctrl-k>[alphabet]s. Please don't recommend me LaTex as this answer since I'm learning it.

Lerner Zhang
  • 740
  • 7
  • 19

3 Answers3

7

Completing the list from Lerner Zhang with lower and upper case superscripts and subscript 'j' (not all ascii chars are available):

execute "digraphs as " . 0x2090
execute "digraphs es " . 0x2091
execute "digraphs hs " . 0x2095
execute "digraphs is " . 0x1D62
execute "digraphs js " . 0x2C7C
execute "digraphs ks " . 0x2096
execute "digraphs ls " . 0x2097
execute "digraphs ms " . 0x2098
execute "digraphs ns " . 0x2099
execute "digraphs os " . 0x2092
execute "digraphs ps " . 0x209A
execute "digraphs rs " . 0x1D63
execute "digraphs ss " . 0x209B
execute "digraphs ts " . 0x209C
execute "digraphs us " . 0x1D64
execute "digraphs vs " . 0x1D65
execute "digraphs xs " . 0x2093

execute "digraphs aS " . 0x1d43 execute "digraphs bS " . 0x1d47 execute "digraphs cS " . 0x1d9c execute "digraphs dS " . 0x1d48 execute "digraphs eS " . 0x1d49 execute "digraphs fS " . 0x1da0 execute "digraphs gS " . 0x1d4d execute "digraphs hS " . 0x02b0 execute "digraphs iS " . 0x2071 execute "digraphs jS " . 0x02b2 execute "digraphs kS " . 0x1d4f execute "digraphs lS " . 0x02e1 execute "digraphs mS " . 0x1d50 execute "digraphs nS " . 0x207f execute "digraphs oS " . 0x1d52 execute "digraphs pS " . 0x1d56 execute "digraphs rS " . 0x02b3 execute "digraphs sS " . 0x02e2 execute "digraphs tS " . 0x1d57 execute "digraphs uS " . 0x1d58 execute "digraphs vS " . 0x1d5b execute "digraphs wS " . 0x02b7 execute "digraphs xS " . 0x02e3 execute "digraphs yS " . 0x02b8 execute "digraphs zS " . 0x1dbb

execute "digraphs AS " . 0x1D2C execute "digraphs BS " . 0x1D2E execute "digraphs DS " . 0x1D30 execute "digraphs ES " . 0x1D31 execute "digraphs GS " . 0x1D33 execute "digraphs HS " . 0x1D34 execute "digraphs IS " . 0x1D35 execute "digraphs JS " . 0x1D36 execute "digraphs KS " . 0x1D37 execute "digraphs LS " . 0x1D38 execute "digraphs MS " . 0x1D39 execute "digraphs NS " . 0x1D3A execute "digraphs OS " . 0x1D3C execute "digraphs PS " . 0x1D3E execute "digraphs RS " . 0x1D3F execute "digraphs TS " . 0x1D40 execute "digraphs US " . 0x1D41 execute "digraphs VS " . 0x2C7D execute "digraphs WS " . 0x1D42

Superscripts should be written like digits superscripts, using <ctrl-k>[alphabet]S.

adrianlzt
  • 171
  • 1
  • 3
7

First off, this answer suggests that there are no unicode subscript letters for all latin characters. However you can still get some of them (a list is provided by several answers in the linked answer) by using :digraphs with argumenst, e.g.

:digraphs as 8336

where 8336 is the unicode encoding of the "LATIN SUBSCRIPT SMALL LETTER A" written in decimal. This will allow you to type <C-K>as and get a subscript a, as desired.

Since unicode encodings are usually given in hexadecimal, I suggest to do the following (here, 2901 is the encoding of "LATIN SUBSCRIPT SMALL LETTER E" in hexadecimal):

:execute "digraphs es " . 0x2091

which lets vim take care of the hex to decimal conversion and will give you the <C-K>es mapping for a subscript e.

For more information, see :help :digraphs

Ingo
  • 986
  • 1
  • 5
  • 11
  • Can I just put :execute "digraphs es " . 0x2091 in the vimrc and let the vim compile it to change the default settings everytime I open or creat a file? I have tried and it doesn't work. How can I do that? – Lerner Zhang Apr 20 '16 at 11:49
7

Thanks for the answer by Lngo. I've my answer posted bellow. I just put these in my ~/.vimrc file:

"alphsubs ---------------------- {{{
        execute "digraphs ks " . 0x2096 
        execute "digraphs as " . 0x2090
        execute "digraphs es " . 0x2091
        execute "digraphs hs " . 0x2095
        execute "digraphs is " . 0x1D62
        execute "digraphs ks " . 0x2096
        execute "digraphs ls " . 0x2097
        execute "digraphs ms " . 0x2098
        execute "digraphs ns " . 0x2099
        execute "digraphs os " . 0x2092
        execute "digraphs ps " . 0x209A
        execute "digraphs rs " . 0x1D63
        execute "digraphs ss " . 0x209B
        execute "digraphs ts " . 0x209C
        execute "digraphs us " . 0x1D64
        execute "digraphs vs " . 0x1D65
        execute "digraphs xs " . 0x2093
"}}}

So I get <ctrl-k>[alphabet]s a shortcut for what I want. In the same way of thinking I can do that for all superscripts. I got all the unicode from that aforementioned repository.

nobe4
  • 16,033
  • 4
  • 48
  • 81
Lerner Zhang
  • 740
  • 7
  • 19