Search code examples
vimsnipmate

Entering text in snippet fields uses wrong character when using langmap


I am using a custom keymap using langmap option in vimrc.

I am trying to use snipmate but I am running into trouble. When I type a word and hit tab it allows me to edit the parameter. The problem is that the first character is the remapped one, while I want it to be the actual key.

For instance, I'll type this:

for

and hit tab to expand the snippet:

for (i = 0; i < COUNT; ++i)

The i is highlighted which means I can edit it. I type "aaa":

for (baa = 0; i < COUNT; ++i) 

It comes out baa even though I typed aaa. This is because I remapped a and b.

How can I fix this?


Here is my keymapping:

set langmap=nj,N},ek,E{,il,IL,{^,}$,lb,LB,uw,UW,ye,YE,jg,JG,\\;z,f\\.,F\\,,zu,ZU,.?,\\,/,/v,?    V,ta,TA,si,SI,ro,RO,ac,AC,wr,WR,xx,XX,dd,DD,bs,BS,gf,GF,pt,PT,kn,KN,cy,CY,vp,VP,o\\;

It won't make much sense to others, and I haven't finalized how I want it to look.


Solution

  • C program which outputs mappings similar behavior to langmap but not for select:

    /* input:
    lhs rhs optional-descripton
    lhs rhs ...
    */
    
    #include <stdlib.h>
    #include <stdio.h>
    
    int main() {
      FILE *fi = fopen("in.txt", "r");
      FILE *fo = fopen("out.txt", "w");
      char lc[8], rc[8];
      while (fscanf(fi, "\n%s %s", lc, rc) != EOF) {
        fprintf(fo, "nnoremap %s %s\n", lc, rc);
        fprintf(fo, "xnoremap %s %s\n", lc, rc);
        fprintf(fo, "onoremap %s %s\n", lc, rc);
        while (fgetc(fi) != '\n');
      }
      fclose(fo);
      fclose(fi);
    }
    

    It doesn't work identically to langmap and so it might break other bindings.