【问题标题】:How to fix Leader Key Beep in Vim?如何修复 Vim 中的 Leader Key Beep?
【发布时间】:2019-07-15 20:53:39
【问题描述】:

我无法让领导密钥在 vim 中工作。我已经解决了很长一段时间了。

我已经做过的事情:

  • 将领导键映射到另一个键
  • 在没有插件/_vimrc 文件的情况下启动 vim

_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"

:让地图队长

mapleader              ;

:地图

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

预期行为

在 vim 屏幕的右下角应该有一个 \(想将 \ll 用于 vimtex),但它只是发出哔哔声。我可以在 CMD-Window 或 vim 插入模式下使用 \,但不能在“普通”-vim-window (ESC, ESC) 中使用它

【问题讨论】:

标签: vim latex vi


【解决方案1】:

尝试将领导键映射到您之前尝试过的另一个键,但将let mapleader = ';' 放在_vimrc 的第一行(而不是最后一行),因为&lt;Leader&gt;&lt;LocalLeader&gt; 已展开定义 map/noremap 时。通过在最后设置领导者会导致之前完成的所有映射(在插件中以及在 mswin.vim 和 vimrc_example.vim 中)无法与新领导者一起使用。

所以_vimrc 将是:

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

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
...
...

【讨论】:

  • 遗憾的是这也不起作用... :map --> 找不到映射
  • @JonasLadner 您是否创建了任何映射?
  • 你能检查一下mapleader是否设置正确吗?在命令模式下尝试:let mapleader。此外,通过:map:imap 检查所有映射。
  • :让mapleader显示“;”但仍然发出哔哔声。感谢您的宝贵时间,我将在“vi 和 Vim 堆栈交换”中试试运气
猜你喜欢
  • 2012-07-04
  • 2014-12-07
  • 1970-01-01
  • 2023-03-29
  • 2018-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多