这是真的开始我的神经,这是奇怪的,因为这是一个小问题.
假设我开始(g)vim 7.3(windows OR linux)没有插件/没有vimrc.我打开一个较长的文件,向下滚动一半.我将光标放在主窗口的底部.我打开一个垂直分割窗口(CTRL W v).
接下来发生的是杀死我光标和它所在的行(原始窗口的底部)跳到窗口的顶部.右侧的新窗口具有原始窗口中光标所在行的原始位置.
我的问题:我如何保持vim不改变我分割的窗口的光标位置?老实说,如果新窗口中的位置发生变化,我不会在意,但拆分原来窗口的事实使我想要撕开我的头发.
以前是完全可以忽视的.然后我有点恼火.然后我慢慢开始变得很懊恼.现在开始让我愤怒了任何帮助/技巧/黑客都非常感谢!
编辑:我的Windows和Linux的vim构建选项(两者都发生):
视窗:
+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 +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 +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +persistent_undo -postscript +printer -profile -Python -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" Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_CSCOPE -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjC/ /Ox /GL -DNDEBUG /Zl /MT -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_BIG /Fd.\ObjC/ /Zi Linking: link /RELEASE /nologo /subsystem:console /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib libcmt.lib user32.lib /PDB:vim.pdb -debug
Linux的:
-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 +fork() +gettext -hangul_input +iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse +mouseshape -mouse_dec +mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +persistent_undo +postscript +printer -profile +python -python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +Syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" user exrc file: "$HOME/.exrc" system gvimrc file: "$VIM/gvimrc" user gvimrc file: "$HOME/.gvimrc" system menu file: "$VIMRUNTIME/menu.vim" fall-back for $VIM: "/usr/local/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng14 -g -O2 -D_FORTIFY_SOURCE=1 Linking: gcc -L/usr/local/lib -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lXt -lncurses -lacl -lgpm -L/usr/lib64/python2.6/config -lpython2.6 -lpthread -lutil -lm -Xlinker -export-dynamic
>:vert split与^ Wv具有相同的行为
>:debug ver split(… cont)确认没有明显的脚本/自动命令干扰
>它只发生在第一次分裂.换句话说,这是一个解决方法:^ Wv ^ Wc ^ Wv
>光标确实不会在原始窗口中移动.左侧显示“新窗口”(您将其命名为原始窗口).这不能显示:echo winnr()或类似的,但你可以通过做例如:vert new而不是:vert split:新的,空的窗口出现在左侧.
而不是这样,你可能会通过以前做一些“无用的”来欺骗分裂来进行“第二次分裂”的行为
:tabnew|bwipeout
现在,^ Wv第一次有所期望的行为.
TL; DR
>这不是一个错误(你对新窗口关闭的期望)
>你可以通过创建另一个窗口来解决它.
其他背景
> splitright,splitbelow options
can be used to control (to an extent) where newly created (split) windows appear
> winrestview()函数
Can be used to explicitely restore the exact view of a window. Use it like so:
06001
savex
now contains something like{'lnum': 1,'leftcol': 0,'col': 0,'topfill': 0,'topline': 1,'coladd': 0,'skipcol': 0,'curswant': 0}
describing the state of the current view.(do stuff,like ^Wv)
06002
This is obvIoUsly a lot more flexible but you might not need it.