1

我正在使用langmapvimrc 中的选项使用自定义键盘映射。

我正在尝试使用 snipmate,但遇到了麻烦。当我输入一个单词并点击选项卡时,它允许我编辑参数。问题是第一个字符是重新映射的字符,而我希望它是实际的键。

例如,我将输入以下内容:

for

并点击选项卡以展开代码段:

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

i突出显示,这意味着我可以编辑它。我输入“aaa”:

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

baa即使我输入了它也会出现aaa。这是因为我重新映射ab.

我怎样才能解决这个问题?


这是我的键盘映射:

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\\;

它对其他人来说没有多大意义,而且我还没有最终确定我想要它的外观。

4

3 回答 3

2

From your :set langmap I understand that you mapped a to c so, by typing aaa, did you expect to obtain ccc?

From what I understand (:help langmap), your custom substitutions are not available in INSERT mode for actually inserting stuff and I don't see a mention of the SELECT mode you are in when overwriting SnipMate's placeholders.

If I do this

:set langmap+=ac,bs

and I type aaa in SELECT mode, I obtain caa.

That's because langmap applies to the first a (:help Select-mode) and, therefore inserts c. But, after this first character I am in INSERT mode for all subsequent characters. Since langmap doesn't apply in INSERT mode, aa is inserted as is.

What is not clear to me is why you obtain baa instead of caa. Your langmap seems to be pretty clear about your intention: you want a to insert c and b to insert s. Typing a shouldn't insert b.

I smell a risk of mistyping in your .vimrc. Try this: reset your set langmap and start adding your mappings one by one.

May I ask you what is the purpose of such a massive remapping?

于 2011-12-12T08:15:37.290 回答
0

输出与 langmap 类似行为但不用于 select 的 C 程序:

/* 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);
}

它与 langmap 的工作方式不同,因此可能会破坏其他绑定。

于 2011-12-12T13:30:12.387 回答
0

这已在 vim 7.4.1150 中修复。有关详细信息,请参阅 https://github.com/vim/vim/issues/572

于 2016-01-22T08:51:52.500 回答