0

I cannot get the leader key working in vim. I have been troubleshooting for quite some time.

Stuff I did already:

  • Mapping leader key to another key
  • :PlugInstall --> Already Installed x Plugin
  • started vim without plugin / _vimrc file (vim -u NONE -U NONE -N)
  • :messages --> does not say anything after beep

This sadly doesn't solve the problem. (Beep)

_vimrc

let mapleader = ';'
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

set nocompatible
syntax on
filetype plugin indent on
set hidden

"let pythonthreedll = 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python36.dll'

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
call plug#end()

" Trigger configuration. Do not use <tab> if you use
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
"let g:UltiSnipsJumpBackwardTrigger="<c-tab>"
"If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

:let mapleader

mapleader              ;

:map

x  <C-A>       * <C-C>ggVG
s  <C-A>       * <C-C>gggH<C-O>G
o  <C-A>       * <C-C>gggH<C-O>G
n  <C-A>       * gggH<C-O>G
v  <C-C>       * "+y
s  <C-H>       * <C-G>c
x  <Tab>       * :call UltiSnips#SaveLastVisualSelection()<CR>gvs
s  <Tab>       * <Esc>:call UltiSnips#ExpandSnippetOrJump()<CR>
   <C-Q>       * <C-V>
s  <C-R>       * <C-G>"_c<C-R>
v  <C-S>       * <C-C>:update<CR>
no <C-S>       * :update<CR>
v  <C-V>       & "-c<Esc>:call paste#Paste()<CR>
no <C-V>         "+gP
v  <C-X>       * "+x
   <C-Y>       * <C-R>
   <C-Z>       * u
o  %             <Plug>(MatchitOperationForward)
x  %             <Plug>(MatchitVisualForward)
n  %             <Plug>(MatchitNormalForward)
   Q             gq
o  [%            <Plug>(MatchitOperationMultiBackward)
x  [%            <Plug>(MatchitVisualMultiBackward)
n  [%            <Plug>(MatchitNormalMultiBackward)
o  ]%            <Plug>(MatchitOperationMultiForward)
x  ]%            <Plug>(MatchitVisualMultiForward)
n  ]%            <Plug>(MatchitNormalMultiForward)
x  a%            <Plug>(MatchitVisualTextObject)
o  g%            <Plug>(MatchitOperationBackward)
x  g%            <Plug>(MatchitVisualBackward)
n  g%            <Plug>(MatchitNormalBackward)
v  gx            <Plug>NetrwBrowseXVis
n  gx            <Plug>NetrwBrowseX
v  <Plug>(MatchitVisualTextObject)   <Plug>(MatchitVisualMultiBackward)o<Plug>(MatchitVisualMultiForward)
o  <Plug>(MatchitOperationMultiForward) * :<C-U>call matchit#MultiMatch("W",  "o")<CR>
o  <Plug>(MatchitOperationMultiBackward) * :<C-U>call matchit#MultiMatch("bW", "o")<CR>
v  <Plug>(MatchitVisualMultiForward) * :<C-U>call matchit#MultiMatch("W",  "n")<CR>m'gv``
v  <Plug>(MatchitVisualMultiBackward) * :<C-U>call matchit#MultiMatch("bW", "n")<CR>m'gv``
n  <Plug>(MatchitNormalMultiForward) * :<C-U>call matchit#MultiMatch("W",  "n")<CR>
n  <Plug>(MatchitNormalMultiBackward) * :<C-U>call matchit#MultiMatch("bW", "n")<CR>
o  <Plug>(MatchitOperationBackward) * :<C-U>call matchit#Match_wrapper('',0,'o')<CR>
o  <Plug>(MatchitOperationForward) * :<C-U>call matchit#Match_wrapper('',1,'o')<CR>
v  <Plug>(MatchitVisualBackward) * :<C-U>call matchit#Match_wrapper('',0,'v')<CR>m'gv``
v  <Plug>(MatchitVisualForward) * :<C-U>call matchit#Match_wrapper('',1,'v')<CR>m'gv``
n  <Plug>(MatchitNormalBackward) * :<C-U>call matchit#Match_wrapper('',0,'n')<CR>
n  <Plug>(MatchitNormalForward) * :<C-U>call matchit#Match_wrapper('',1,'n')<CR>
v  <Plug>NetrwBrowseXVis * :<C-U>call netrw#BrowseXVis()<CR>
n  <Plug>NetrwBrowseX * :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())<CR>
s  <Del>       * <C-G>c
s  <BS>        * <C-G>c
s  <C-Tab>     * <Esc>:call UltiSnips#ListSnippets()<CR>
o  <C-F4>      * <C-C><C-W>c
nv <C-F4>      * <C-W>c
o  <C-Tab>     * <C-C><C-W>w
nx <C-Tab>     * <C-W>w
v  <S-Insert>    <C-V>
no <S-Insert>    "+gP
v  <C-Insert>  * "+y
v  <S-Del>     * "+x
x  <BS>        * d
v  ÎØ            "*d
v  Î×            "*d
v  ÎÕ            "*y
v  ÎÔ            "-d"*P
n  ÎÔ            "*P
nv Îu            <C-End>
nv Îw            <C-Home>

:imap

i  <C-F4>      * <C-O><C-W>c
i  <C-Tab>     * <C-R>=UltiSnips#ListSnippets()<CR>
i  <S-Insert>    <C-V>
i  ÎÔ            <C-R><C-O>*
!  Îu            <C-End>
!  Îw            <C-Home>
i  <C-A>       * <C-O>gg<C-O>gH<C-O>G
i  <Tab>       * <C-R>=UltiSnips#ExpandSnippetOrJump()<CR>
i  <C-S>       * <Esc>:update<CR>gi
i  <C-U>       * <C-G>u<C-U>
i  <C-V>       & <C-G>u<C-\><C-O>"+gP
i  <C-Y>       * <C-O><C-R>
i  <C-Z>       * <C-O>u

Expected Behavior

On the bottom right vim screen there should be a ; (want to use ;ll for vimtex) but it just beeps. I can use ; in CMD-Window or vim insert mode but can't use it in the "normal"-vim-window (ESC, ESC)

### Another Problem with vimtex I can't use the :VimtexCompile command. My Bad... You can only use those commands while editing a .tex file

  • In the current state it is very complicated to help you with your question. Here are a few tips: Reduce your vimrc to get a minimal setup which reproduces the problem. You mentioned stuff you already did but you don't tell us what happened when you tried that. You say "bottom right vim screen there should be a ;" I guess you are referring to :h 'showcmd' which shows the beginning of the command you started typing is that right? And finally you say "it just beeps": have you tried using :message to see the reason of the bip? – statox Jul 18 at 16:19
  • @statox I added some information – Jonas Ladner Jul 18 at 18:35
  • You should follow how to debug my vimrc and as I said before: create a vimrc with only the minimal config to reproduce your problem. And the problem with the vimtex command seems unrelated. – statox Jul 19 at 9:53
  • @statox if I start vim without any config the problem persists. – Jonas Ladner Jul 19 at 11:49
2

If I understand your question correctly, you are trying to use the vimtex keybinding for the <plug>(vimtex-compile) command and you're expecting it should be available under ;ll, since you have let mapleader = ';' at the start of your _vimrc.

If that's the case, the problem you're having is that vimtex actually uses the <localleader> (not <leader>) for its mappings, so it will actually map the <plug>(vimtex-compile) to \ll and not ;ll, since your maplocalleader is unset and the default for <localleader> is a backslash.

See :help vimtex-default-mappings, which explicitly documents that:

Many of the mappings utilize the |maplocalleader|.

And lists the mapping for compiling:

<localleader>ll <plug>(vimtex-compile)

If you want to use ;ll for compiling instead, add this to the start of your _vimrc:

let maplocalleader = ';'

You might want to remove the mapleader setting (let it default to \) or set it to some other key, since most of the point of setting those variables is to have different keybindings for global and local commands, in order to avoid clashes.

Also, please remember that these keybindings from vimtex, such as ;ll (and, more generally, keybindings that use <localleader>) are only defined for buffers where vimtex enables them, which is usually for the appropriate filetype, in this case, .tex.

Same as you noticed :VimtexCompile will only work in such a buffer, same is true for the corresponding keybinding.

  • 1
    Good catch! This came from SO too and no one had any luck figuring it out. Hope this it – D. Ben Knoble Jul 19 at 21:52
  • 1
    I was actually the one to point the OP to Vi & Vim.SE 😁 but took me a while to fully "parse" this one... – filbranden Jul 19 at 21:59
  • 1
    Wow figuring this out from this very unclear question was pretty impressive! Well done @filbranden ! :) – statox Jul 20 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.