Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know that in insert mode I could navigate through the document by using the arrow keys or by using Ctrl-o to escape insert mode temporarily. My question is: Is there any other way to navigate through documents instead of using those keys or temporarily escaping?

Thank you.

OK guys, just found a solution for my own question in which I use imap to map keys in Vim in insert mode.

 imap <C-n> <Down>
 imap <C-p> <Up>
 imap <C-@> <C-Space>
share|improve this question
7  
Vim is designed for navigation to be done in normal mode and text insertion to be done in insert mode. You will be much happier and more productive in the long term if you learn to use Vim the way it was designed to be used instead of fighting it. If you try it for a while and find you really don't like a moded editor, you may want to try Emacs. It is another very powerful editor, but lets you navigate and edit without changing modes. –  garyjohn Jan 7 '13 at 7:05
    
if you dont care for modes, you could give... emacs... a whirl. shudders –  ash Jan 8 '13 at 4:33

3 Answers 3

up vote 2 down vote accepted

Another upvote for @garyjohn's comment, here.

By following that path, you are certainly shooting yourself in the foot. I see at least two big mistakes in your approach.

  • As @garyjohn wrote, you are "fighting" against Vim's most crucial aspect. Modality is at the core of everything that makes it the awesome text editor it is. If you consider its proverbially steep learning curve, actively going against its design won't get you far up.

  • Like many others, you focus your "dumbing down Vim" effort on movements like <up>, <down> and friends. Vim has much better ways to move around in and between buffers: wWeEbB/?tTfF{}[] and so on. All these motions give you super powers. All these motions depend on modality in one way or another.

    Rejecting these incredibly useful tools is a very bad mistake in and of itself. Remapping them would be both very tough and utterly worthless.

    FYI, when I started Vim, I spent months trying to turn it into a TextMate clone. Trying to create insert mode mappings for everything was probably one the most frustrating endeavour of my whole career. I learned two things in the process, though:

    1. my beloved TextMate was seriously underpowered compared to Vim so it made absolutely no sense to dumb down Vim, and…

    2. modes freaking rule.

Accept Vim's philosophy instead of rejecting it. Or reject it and use Sublime Text 2 instead, for what we care.

share|improve this answer

Just to hammer this home: If you stay in insert mode for long, you're doing something wrong. The pattern in Vi(m) is: Move around in normal mode. Make short inserts (a word here, a sentence there). Or manipulate the text with Ex commands like :substitute. Repeat.

Try to teach yourself to leave insert mode (via <Esc>, hopefully conveniently accessible on your keyboard) as soon as the stream of characters coming from your brain starts to trickle off. The next insertion is just an i / a away.

share|improve this answer

I agree with @garyjohn - besides, Ctrl-n and Ctrl-p are things I use for autocompletion or automatic spelling completion - I wouldn't map those to something else. All the same, Ctrl-w will delete one word before the cursor, and Ctrl-u will delete everything before the cursor, so at least you could use these shortcuts (which also work in a shell).

share|improve this answer
1  
Another reason to avoid abusing insert mode (i.e., by using it all the time) is that the user would be sidestepping Vim's standard undo/redo functionality. For example, if you make a series of changes in insert mode, then escape to normal and undo with u, you will undo all changes made. Additionally, Ctrl-u in insert mode is not easily redoable (unlike normal mode deletion commands). The user can still rely on :earlier and :later but loses granularity in the undo tree unless using Ctrl-G u See vim.wikia.com/wiki/Using_undo_branches –  Andy Mo Jan 9 '13 at 14:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.