6

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.

4

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

| improve this answer | |
  • 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
4

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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