Vim: <Ctrl-h|j|k|l> for Movement in Insert Mode [closed]
开发者_开发问答
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this questionI'm being quite new to Vim and I consider setting it up so I can use Ctrl + movement keys (H, J, K, L) for moving around in Insert mode.
Two questions:
- How is this set in
.vimrc
? - Is this recommendable (at least the slightest considerable), or just plain 'backwards'?
Did you know that CTRL-O in insert mode temporarily switches to normal mode for one normal-mode command? So, CTRL-O j, CTRL-O k, etc. But also CTRL-O ^, etc.
You can achieve what you want with these mappings:
inoremap <c-k> <up>
inoremap <c-j> <down>
inoremap <c-h> <left>
inoremap <c-l> <right>
I don't see anything really wrong with it, although you obviously lose the existing mappings (e.g. <c-l>
to redraw the screen.
Vi purists will probably baulk at the idea of staying in insert mode whilst navigating around your file, but there are worse sins.
People already told you how to do this, so I just want to answer the second part of your question.
I don't quite get the point of using Vim and not using the power of modes. The main problem with this setup is that you are limiting your movement power to "one character in any direction". This is not "wrong", this is just inefficient. What about F
, f
, T
, t
(moving forward/backward to a char)? What about 0
and $
(moving to the beginning and the end of line)? What about paragraph/sentence movements ([]{}
)? What about going to the matching parens (%
)? Etc, etc, etc.
IMO, it is better to learn to use the full power of normal mode movements, than to reduce your movement abilities to hjkl
精彩评论