为什么这两个关键字中的一个在几乎完全相同时会崩溃?

时间:2013-01-16 02:04:22

标签: vim

这个问题显然远远超出了我对Vim的理解。这两个关键字绑定只有两个字符,否则它们完全相同。

" Move viewport up/down.
noremap <C-d> :exe "normal! " . (winheight(".") / 4) . "\<C-e>"<CR>
noremap <C-u> :exe "normal! " . (winheight(".") / 4) . "\<C-y>"<CR>

然而,底部的一个(<C-u>)完全按预期工作,而顶部的一个导致此错误:

  <\ n> E114:缺少引语:“\”   E15:表达式无效:“正常!”。 (winheight(“。”)/ 4)。 “\”

我重新启动了Vim两次,并确保只有这些命令绑定到他们的键。我也试过切换它们,如果由于某种原因相关,但<C-d>命令仍然崩溃。

那么Waldo在哪儿?


gvim.exe --version的输出:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 16 2010 10:31:31)
MS-Windows 64-bit GUI version with OLE support
Compiled by george@reilly.org
Huge version with GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +gettext/dyn -hangul_input 
+iconv/dyn +insert_expand +jumplist +keymap +langmap +libcall +linebreak 
+lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse 
+mouseshape +multi_byte_ime/dyn +multi_lang -mzscheme +netbeans_intg +ole 
-osfiletype +path_extra -perl +persistent_undo +postscript +printer +profile 
+python/dyn -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs 
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl -tgetent -termresponse +textobjects +title 
+toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup -xfontset -xim 
-xterm_save -xpm_w32 
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$VIM\_gvimrc"
    system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE 
-DFEAT_NETBEANS_INTG      -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  /Fo.\ObjGOY/ /Ox /GL -DNDEBUG  
/Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DFEAT_GUI_W32 
-DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_PYTHON -DDYNAMIC_PYTHON  
-DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DMSWINPS -DFEAT_HUGE /Fd.\ObjGOY/ /Zi
Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib 
shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:AMD64 /nodefaultlib gdi32.lib version.lib   
winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:AMD64 /nodefaultlib libcmt.lib oleaut32.lib  user32.lib

我从官方Vim下载页面上的链接下载了Vim:

http://code.google.com/p/vim-win3264/downloads/list

1 个答案:

答案 0 :(得分:6)

noremap<C-e>之前解释<C-y>exe,因此exe将被提供控制序列,这些控制序列不一定被正确解释。一种可能的解决方法是定义命令然后映射到它们:

com! ShiftDown exe "norm!" winheight(".")/4 . "<C-e>"
com! ShiftUp exe "norm!" winheight(".")/4 . "<C-y>"
noremap <C-d> :ShiftDown<CR>
noremap <C-u> :ShiftUp<CR>

也可以使用<C-v> <C-e><C-v> <C-y>直接映射命令,以插入这些字符:

noremap <C-d> :exe "norm!" winheight(".")/4 . "<C-v><C-e>"<CR>
noremap <C-u> :exe "norm!" winheight(".")/4 . "<C-v><C-y>"<CR>

或者,<LT>可用于插入文字<

noremap <C-d> :exe "norm!" winheight(".")/4 . "<Bslash><LT>C-e>"<CR>
noremap <C-u> :exe "norm!" winheight(".")/4 . "<Bslash><LT>C-y>"<CR>

N.B。虽然文字\可能有用,:help map建议使用<Bslash>安全。