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'm learning gVIM on Windows, and as I slowly learn more of the keystrokes I find myself using the mouse less and less, which is great.

I have a couple of questions I've yet to figure out:

  1. I do a lot of copy and paste. So I use 'v' to enter VISUAL mode, use k/j to move up/down and select the lines, then hit 'y' to yank.

I then go to the line where I want to insert, and hit 'p' to put, BUT the darn thing pastes after the 1st character. I can't move any further left, so I am definitely at the start of the line, so I find the 'p'ut behaviour of pasting 1 char after my cursor position to be supremely annoying.

  1. I switch between edit and command mode an awful lot, and my poor little finger on my left hand is getting sore from being stretched out to hit the 'Esc' key (to enter command mode) every few seconds. Is there a more finger-friendly way to enter command mode?
share|improve this question
1  
You should really ask your second, unrelated question as a separate question. –  bignose Mar 23 '10 at 1:48
1  
What you call "command mode" is actually called "normal mode". Command mode is what you get when you press : in normal mode. –  frabjous Oct 22 '10 at 4:59
add comment

3 Answers

up vote 8 down vote accepted

The "put" command puts the register text after the cursor, as you've discovered. But if you :help put, you'll see the P command which puts the text before the cursor:

                                                        *p* *put* *E353*
["x]p                   Put the text [from register x] after the cursor
                        [count] times.  {Vi: no count}

                                                        *P*
["x]P                   Put the text [from register x] before the cursor
                        [count] times.  {Vi: no count}

This also operates analogously with full lines from the register; p will put the text on new lines following the cursor, P will put the text on new lines preceding the cursor.

share|improve this answer
add comment

On the topic of Question 2... or actually your second Question 1 ;) :

You have at least two options here.

  • use CTRL-C instead of ESC. This is convenient and doesn't require any configuration. The downside is that it doesn't work in exactly the same way as ESC: for example, if you have just created an abbreviation, and then hit CTRL-C, the abbreviation will not be expanded; whereas if you had it ESC instead, it would have. I think most of the stuff where this matters is more advanced, so it may not matter too much for now, but you may end up getting confused later on when trying to learn new things and wondering why they don't work for you.

  • use CTRL-[ instead of ESC. I'm not totally sure that this works under Windows but at least on linux using console-mode vim it is an exact substitute for ESC. It's kind of inconvenient though because you need to use both hands to do it. I find that on most keyboards it actually ends up being easier to hit ESC than to combo this. But then I never really tried to teach my fingers to hit it quickly.

  • add a mapping in your vimrc or gvimrc to map something else to ESC. some people use a quick succession of jk. I've never done this, partly because I'd prefer to avoid flailing helplessly when attempting to use a system that doesn't have this set up. But if you want to learn how to do it, it should be readily googlable.

  • remap an unused key to ESC through your operating system. The archetypical example here is to remap CAPS LOCK to ESC. It's on the home row, it's big, it's mostly useless otherwise: it's an easy target. I'm not sure how to go about doing this under Windows, or if it's even possible. Also if you actually like Caps Lock for Caps Locking then it's obviously not a good idea, as it will cease to function in that capacity. An upside to this strategy is that it alleviates the possibility of wondering why the hell vim is going into seizures whenever you accidentally hit caps lock. The downside, as with vimrc mappings, is that you can get pretty confused when you try to use (g)vim on another system.

share|improve this answer
add comment

Personally I turn on the line numbers by doing the command :set nu

Then I look at the numbers and calculate the number of lines I want to paste...(say 5 lines for example)...then I move the cursor to the top line that I want to copy and type 5Y....this will copy the next 5 lines....then move the cursor to the position you want to paste the text and type p to paste below the cursor or P to paste above the cursor.

Hope this helps.

share|improve this answer
    
bad form, calculating... sheesh. human brain regularly only handles 7 to 10 concepts simultaneously, the consideration of keystrokes taken by one and then you want a calculation... involving 3 more numbers?! no way. –  Joshua Kersey Mar 24 '10 at 22:47
    
well, I would have to disagree with you on that....my experience is that once I had been using vim for a while I could guess the number of lines by just looking at the screen. But if you don't want to do that you can use the visual commands. –  kiwiburger Apr 2 '10 at 20:43
add comment

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.