2

I'm using ctrlP plugin.

According to the ctrlp's doc I should be able to remap like this

  let g:ctrlp_prompt_mappings = { 'PrtSelectMove("k")': ['<c-u>', '<up>'] }
  let g:ctrlp_prompt_mappings = { 'PrtSelectMove("j")': ['<c-d>', '<down>'] }
  let g:ctrlp_prompt_mappings = { 'PrtDelete()'       : ['<c-k>', '<del>'] }
  let g:ctrlp_prompt_mappings = { 'PrtExit()'         : ['<c-l>', '<esc>'] }

But it doesn't work, I tried a few variations - still getting the same result.

I want to remap this four lines (from doc):

\ 'PrtDelete()':          ['<del>'],
\ 'PrtSelectMove("j")':   ['<c-j>', '<down>'],
\ 'PrtSelectMove("k")':   ['<c-k>', '<up>'],
\ 'PrtExit()':            ['<esc>', '<c-c>', '<c-g>'],

+++UPDATE+++

  let g:ctrlp_prompt_mappings = {
  \ 'PrtDelete()': ['<c-k>', '<del>'],
  \ 'PrtExit()': ['<esc>', '<c-l>', '<c-g>'],
  \ 'PrtSelectMove("k")': ['<c-u>', '<up>'],
  \ 'PrtSelectMove("j")': ['<c-d>', '<down>'],
  \}

Only <c-u> does work. <c-k>, <c-l>, <c-d> doesn't work.

when I do :echo g:ctrlp_prompt_mappings

{'PrtDelete()': ['<c-k>', '<del>'], 'PrtSelectMove("j")': ['<c-d>', '<down>'], 'PrtExit()': ['<esc>', '<c-l>', '<c-g>'], 'PrtSelectMove("k")': ['<c-u>', '<up>']}

+++UPDATE2+++

  let g:ctrlp_prompt_mappings = {
  \ 'PrtExit()':   ['<c-l>', '<esc>'],
  \ 'PrtSelectMove("k")': ['<c-u>', '<up>'],
  \ 'PrtSelectMove("j")': ['<c-d>', '<down>'],
  \ 'PrtBS()': ['<c-k>', '<bs>', '<c-]>'],
  \ 'ToggleByFname()': [''],
  \ 'PrtCurRight()': ['<right>'],
  \}

everything works. ( <c-l>, <c-d> ) started working because I remove them from

  \ 'ToggleByFname()':      [''],
  \ 'PrtCurRight()':        ['<right>'],
4

1 回答 1

3

如果您将建议的解决方案复制到剪贴板,

  let g:ctrlp_prompt_mappings = { 'PrtSelectMove("k")': ['<c-u>', '<up>'] }
  let g:ctrlp_prompt_mappings = { 'PrtSelectMove("j")': ['<c-d>', '<down>'] }
  let g:ctrlp_prompt_mappings = { 'PrtDelete()'       : ['<c-k>', '<del>'] }
  let g:ctrlp_prompt_mappings = { 'PrtExit()'         : ['<c-l>', '<esc>'] }

,然后使用“源”它:@+,你会注意到你实际上覆盖了变量三次,所以只剩下最后一行:

:echo g:ctrlp_prompt_mappings

output: {'PrtExit()': ['<c-l>', '<esc>']}

如果您遵循文档中描述的模式会更好:

 *'g:ctrlp_prompt_mappings'*
Use this to customize the mappings inside CtrlP's prompt to your liking. You
only need to keep the lines that you've changed the values (inside []): >
let g:ctrlp_prompt_mappings = {
\ 'PrtBS()': ['<bs>', '<c-]>'],
\ 'PrtDelete()': ['<del>'],
\ 'PrtDeleteWord()': ['<c-w>'],
\ 'PrtClear()': ['<c-u>'],
\ 'PrtSelectMove("j")': ['<c-j>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-k>', '<up>'],
...
\}

每个大括号块都包含一个字典。您的方法定义了四个不同的字典并将它们全部分配给同一个变量,而文档描述的形式定义了一个具有多个键/值对的单个字典。查看:help dict更多信息。

于 2015-09-30T11:24:41.293 回答