Vim: Leader not working
Asked Answered
G

5

12

When trying to use vim-latexsuite's mappings, the ones using Leader are not working:

:nmap
----------------------------------------
n  <Leader>rf   @<Plug>Tex_RefreshFolds
n  <Leader>ls   @<Plug>Tex_ForwardSearch
n  <Leader>lv   @<Plug>Tex_View
n  <Leader>ll   @<Plug>Tex_Compile

All other mappings by this plugin are working, so the plugin is being loaded correctly. Without mapleader being set, Leader should default to \ (Backslash).

When typing \ll in command mode, the cursor gets moved 2 characters to the right, as it's supposed to by just typing ll. So the Backslash seems to be ignored. Vim does not beep or display any errors and the ll follows earlier than 1000ms, which is my timeoutlen.

I have also tried the following settings in both .vimrc and /etc/vimrc (Though I assume only mapleader needs to be set here):

let mapleader = ","
let maplocalleader = ","

After this, Vim behaves the same way: No beep, no error and after typing ,ll the cursor moves 2 characters to the right.

Any ideas how to fix this?

Governess answered 19/7, 2012 at 11:53 Comment(9)
What do you get when you type :echo mapleader? :verbose nmap \?Mull
:echo mapleader -> , and :verbose nmap \ (or ,) -> No mapping foundGoverness
Here, :nmap and :nmap <leader> don't return n <Leader>b SomeCommand but n ,b SomeCommand. Note that <leader> is expanded to its value. It looks to my untrained eyes as if the value of mapleader would be set to the string <Leader>, which seems quite weird.Mull
This may not be the case here but it's a useful tidbit nonetheless.. If mapleader is changed after a plugin is already loaded the new mapleader will not be a part of the mappings for that plugin. Another quirk with mapleader.Frizzell
Manually reinstalling the plugin didn't change anything. Any more ideas?Governess
If you edit the plugins code and make a mapping next to the other ones that just echo's "test", does it work?Chaffer
Do you mean something like this: :nnoremap <Leader>d dd I added this to my .vimrc and :nmap returns n <Leader>d * dd. When i type ",d", only one "d" is being shown in the bottom right corner. So it doesn't work either. As i said in the Question, the other mappings of the plugin are working.Governess
Have you seen this? #8189555Chaffer
Yes, and my let mapleader = "," is at the top of my .vimrc. But even without that working, the Leader should default to \, which doesn't work either (Both \ and , seem to be ignored by Vim).Governess
M
11

If you've shortened timeoutlen, you won't be able to type quickly enough. If you look at :help 'ttimeoutlen', you'll see it suggests:

:set timeout timeoutlen=3000 ttimeoutlen=100
Mussman answered 1/11, 2017 at 23:7 Comment(0)
P
5

Try to clear a content of ~/.viminfo file and if you are using a session plugin -- clear a session data in generated file. Then restart Vim. It helps me sometimes when I experiment with different settings, mappings etc.

Patronage answered 5/1, 2014 at 11:33 Comment(1)
This worked for me. I had the same problem as the original post, and when I deleted the .viminfo and reloaded, the remapped leader key worked as expected.Clower
G
1

After uninstalling Vim, removing all plugin and config files and reinstalling it, the Leader works just fine. Unfortunately, i don't know what exactly caused Vim to ignore the Leader.

Governess answered 20/7, 2012 at 16:13 Comment(1)
In my case, I had some conflicting "let mapleader" leader changes in a couple ~/.vim/ftplugin/tex_*.vim that were executing in the wrong order. Having them execute in the right order solved it for me without a reinstall.Arium
R
0

If you have a mapping like this in your .vimrc,

nmap <Leader>rf @<Plug>Tex_RefreshFolds

then the output of nmap (without arguments) should be this:

n  \rf   @<Plug>Tex_RefreshFolds

In other words, "<Leader>" should be expanded to "\". Since this is not the case for you, something is going wrong with your mapping. This could be caused by having "<" in your cpoptions. Try set cpoptions? to check.

Randarandal answered 18/1, 2017 at 20:42 Comment(0)
S
0

I found that setting the mapleader doesn't work in vi compat mode. In case you're executing vim with the -u flag (for specifying the configuration file) this will set the vi compatability mode. You then also need the -N flag to disable vi-compatability mode again to make it behave correctly:

vim -Nu ~/.config/vim/vimrc .

You could probably also try :set nocompatible from within vim to disable it manually and then try if the leader key works.

More info here: In a .vimrc, is set nocompatible completely useless?

Sprouse answered 21/7, 2024 at 6:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.