20

I want to be able to select columnar blocks using only the keyboard when I use GVim on Windows, but I do not seem to be able to do so when using gvim (7.2) on Windows XP. Edit: For convenience, it is preferable to make the selection with arrow keys as is commonly done in other versions of vi/vim.

In a terminal, when using vim, to define a block, one may select columnar blocks by pressing Ctrl-V and by conveniently moving the cursor with the arrow keys.

When using GVim on mswin, Ctrl-V is mapped to a paste operation. Every reference found on this topic mentions that on mswin, Ctrl-Q is set to act the same way that Ctrl-V works on other platforms, but this does not work for me.

After research indicated that the Ctrl-Q behavior is implemented through the inclusion of mswin.vim, it seemed that perhaps mswin.vim was not being loaded by GVim. mswin.vim is apparently loaded via _vimrc. It seemed that perhaps mswin.vim was not loading, so perhaps _vimrc was not setup correctly, but...

C:\Program Files\Vim\_vimrc exists contains:

source $VIMRUNTIME/mswin.vim
behave mswin

C:\Program Files\Vim\vim72\mswin.vim exists and contains:

" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q>       <C-V>

C:\Program Files\Vim\_vimrc should load since Edit | Settings Window in the GVim graphical menu loads this file for editing, and it is clear that C:\Program Files\Vim\vim72\mswin.vim is loading because one can insert a syntax error in that file and GVim will complain about it when it starts up (it was backed it up for testing and restored to prevent accidental corruption).

When Ctrl-Q is pressed, the cursor changes in the same way that it changes when you block select text using the mouse, but any cursor movement at this point causes the cursor to change back to a normal cursor. It does not matter whether one continues to hold Ctrl, Ctrl-Q, or not.

Edit: Ctrl-Q enters block selection mode as indicated by the cursor change since other cursor movement commands extend the block, however, the original intent of this question was to learn how to use the arrow keys (in the same manner that they are able to be used in other implementations of the editor) though this was not explicitly stated in the original, unanswered revisions of the question.

It is possible to visually select columnar blocks by pressing Alt while holding down the left-mouse button, but Alt during arrow key motion after pressing Ctrl-Q also does not work.

Research also seemed to indicate that pressing v in command-mode would enter visual-mode, and that perhaps this was relevant, but using this does not seem to help the situation.

C:\Program Files\Vim\vimfiles does not contain anything except an empty directory structure. C:\Documents and Settings\username does not contain vim configuration files, nor does C:\Documents and Settings\username\My Documents. Other C:\Documents and Settings\username locations, where application-specific or local settings are commonly stored, also appear not to have vim settings. The same is true for %HOMEDRIVE% and for the environment variables.

4

3 回答 3

20

仅使用键盘在 Win32 上的 GVim 中直观地选择列块的一种方法是按下,释放它,然后在使用箭头键选择列块的同时Ctrl-Q按住键。Shift

为什么Ctrl-Q列选择会以这种方式运行尚不清楚,但这并不重要,因为目标是仅使用键盘来选择列块。在 Vim 中,用于选择块Shift时不使用。Ctrl-V

:help mswin没有提到CTRL-V替代方案的这种细微差别。

于 2013-01-04T20:06:49.417 回答
3

最好的办法是从你的 vimrc 中删除这些行。它们完全没有必要,并且改变了太多基本的 Vim 特性。

于 2013-01-04T20:23:24.773 回答
0

noremap <C-Q> <C-V>mswin.vim 中的将原始命令重新映射为Ctrl+ Q

如果包含 mswin.vim,按Ctrl+后Q,指示模式应切换到Visual Block,并且任何移动(例如jlw)都会扩展视觉选择。如果这对你不起作用,你可能有一些干扰。

这些运动命令本身是重新映射的,还是有一个autocmdon CursorMoved?!尝试禁用您的插件 ( vim --noplugin) 和大部分.vimrc.

请注意,光标键通常不会构成正确的移动(并且它们在 Vim 中的使用是不受欢迎的)。

您认为扩展选择的正确(也是唯一)方法(使用移动的光标键)只是 的结果:set selectmode=key,正如:behave mswin.

于 2013-01-05T11:37:03.993 回答