Vim: underscore(_) automatically converted to (<-)

白昼怎懂夜的黑 提交于 2019-12-20 05:37:18

问题


I have been writing R scripts in Vim for some time now. Starting an hour ago, I began facing an issue that every time I type an underscore (_), it gets automatically converted to <-.

What setting did I change for this to happen? Thanks!


回答1:


:verbose imap _ should tell you which (probably filetype plugin) has set this.

It's less likely to be an abbreviation, but :verbose ia _ would tell you.




回答2:


The VIM: r-plugin does indeed change the mapping but the documentation section 4.1 states "it is possible to insert an actual underscore into your file by typing a second underscore".

Thus, while you can disable the conversion of _ to <- it is easy to override temporarily.




回答3:


It may be also worthwhile to add that a convenient setting may involve re-assigning the operator, for instance the .vimrc setting:

" Nvim-R extra settings
"" Change assignment operator
let R_assign_map = "|"

Would assign the r assignment operator <- to Shift+|. This feature is described ithe provided documentation. In the R_assign section.




回答4:


To add more options to what you can do, Nvim-R has not only R_assign_map as @konrad pointed out, but R_assign which manages how the feature works. A previous answer on duplicate answer mentioned an outdated version of R_assign (older name) being set to 0 as the answer.

I have found that the actual way to use this variable as of at least this post date (while the variable is still called R_assign) that there are 2 valid values thus 3 functions. I have only tried values of -1 to 3, but I found 1 and 2 to produce something, so here they are:

  • Invalid values (let R_assign=-1 (anything but 1 and 2)) made it so that _ produced <- and any subsequent _ keys produced more <-
  • let R_assign=1 produced the default documented behaviour of 1 _ makes a <- and the next _ makes (thus two _) a single _
  • let R_assign=2 flips it so that a single _ makes _ and another _ makes a <- (so two _ for a <-)


来源:https://stackoverflow.com/questions/22380926/vim-underscore-automatically-converted-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!