简体   繁体   English

为什么我的vim映射不起作用?

[英]Why doesn't my vim mapping work?

I followed the guide here to create vim mapppings. 我按照这里的指南创建了vim mapppings。 Put the following in my .vimrc file 将以下内容放在我的.vimrc文件中

let mapleader=','
if exists(":Tabularize")
  nmap <Leader>a= :Tabularize /=<CR>
  vmap <Leader>a= :Tabularize /=<CR>
  nmap <Leader>a: :Tabularize /:\zs<CR>
  vmap <Leader>a: :Tabularize /:\zs<CR>
endif

The page says when I type ,a= it should tell Tabularize to align my lines. 页面说当我输入时,a=它应该告诉Tabularize对齐我的线条。 But instead it inserts the character = where the cursor is. 但是它会插入游标所在的character =

I have Tabularize installed and the :Tabularize command does work when I call it without mapping. 我安装了Tabularize,并且:Tabularize命令在没有映射的情况下调用它时可以正常工作。

What am I doing wrong? 我究竟做错了什么?

Your .vimrc file is read and executed before plugins are loaded, so :Tabularize isn't defined. 在加载插件之前读取并执行.vimrc文件,因此:Tabularize未定义:Tabularize

To find out the exact order in which the various scripts are called at startup you can run the command: 要找出启动时调用各种脚本的确切顺序,可以运行以下命令:

:scriptnames

and you can learn the details about the initialization process with: 您可以通过以下方式了解初始化过程的详细信息:

:help startup

Make sure that you set your mapleader to , . 确保将mapleader设置为, Originally it is mapped to \\ . 最初它被映射到\\

To accomplish this add this to your vimrc or type in the command window: 要完成此操作,请将其添加到vimrc或在命令窗口中键入:

let mapleader=","

Although from your code it looks like you are doing this, you have to make sure that it didn't get reset somewhere. 虽然从您的代码看起来您​​正在这样做,但您必须确保它不会在某处重置。 In order to see what it is set to currently type let mapleader in the command window. 为了查看当前设置的let mapleader ,请在命令窗口中键入let mapleader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM