tags:

views:

1107

answers:

14

I've been using Vim for quite a long time, but I'm at a level where I use insert mode most of the time, and I still use the arrow keys to move around(!).

I feel like I'm not getting the best out of my lovely editor, particularly regarding navigating (especially code), copy & pasting, and doing other manipulations of existing code. (though I am quite comfortable with complicated search/replace patterns).

  • How should I go about learning more?
  • What resources would people recommend?
+2  A: 

Learning the vi and vim editors.

Alex
+9  A: 
  1. type vimtutor on the command line
  2. go into vim, type :help or <F1>
  3. subscribe to mailing list
  4. official vim docs
ghostdog74
The one thing I hadn't considered was joining the mailing list: done now :)
Autopulated
its a good place to get help and practice your vim skill by solving other's people's problems.
ghostdog74
+1 for vimtutor - excellent way to get the vim way into your muscle memory.
Hamish Downer
+1  A: 

How should I go about learning more?

Read vim manual completely (type :h; you can browse from there). This is how you get to know all of the movements and commands. That's most useful if you already know the basics and want to improve.

What resources would people recommend?

vim.org, look through the most popular vim scripts. Check sources of them if you find something of interest. Or just install them and enjoy. That site comprises a lot of links to scripts that help browsing source code in different languages; and it is relatively easy to find them there.

StackOverflow.com also might be of help.

Pavel Shved
+13  A: 

This article is a nice introduction to "the Vim way", especially about text objects which are one of the most defining features of Vim.

kemp
As a bonus, there is a nice graphical cheat sheet (linked at the end of the article).
Csaba_H
A: 

I still use the arrow keys to move around(!).

I don't see a problem with this.

Frankly, what's the probability that you'll have to use vim and a keyboard that lacks arrow keys?

You know, most people use vim because it does the job (oh well, because they mastered it to a level when it does the job for them), not for being elitists (like not using the arrow keys).

A couple of advices for improving your vim knowledge:

  • periodically open the vim help at a random place and read about a random distinct feature. It will take you a couple of minutes. It's possible that you won't use this feature during next X years. But if you are lucky, you'll be in a situation when you'll see that you can apply your knowledge about that feature to achieve a certain task. You'll open the help again to refresh your memory. After using the feature in practice for a couple of times, it'll stick. At this point your vim knowledge will be improved.
  • use :helpgrep to dig into random places of documentation. If you need to do something and you find the place that explains it in the docs, don't stop there. Read the doc snippet one more time. Find the keywords. For each keyword, use :helpgrep keyword to discover the logical links with other parts of the vim documentation.
Alex_coder
I guess the problem I have with just reading documentation is that I find I don't learn things very effectively without actually *doing* them.
Autopulated
Using cursor keys to move your cursor for short distances can be just as efficient as using the [h], [j], [k], [l] keys ... if your fingers happen to be near them for some other reason.Using any linear cursor movements is horrid for more than a few columns or lines of movement. Usually it's best to think about what you're looking for and express that directly in vi using the / or ? commands and regular expressions. Last bit of text near foo? G?foo[Enter] (six keystrokes). First line with "bar ... something .. bang in it? 1G/bar.*bang[Enter] (about a dozen keystrokes) ... and so on.
Jim Dennis
+2  A: 

See this thread: http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim

Especially the first answer.

Konrad Garus
As the author of the "first" answer I have to say, in all fairness, that it's not necessarily the best guide for generally improving your mastery of the editor. It covers lots of ground about what can be done with vi when you think of it as a language for expressing the ways that you want to manipulate the text, your screen/terminal and the environment of the editor itself. However, lots of the stuff in there is pretty advanced.
Jim Dennis
I have learn't so much from reading that answer that I don't think I would ever have learn't by reading documentation!
Autopulated
+5  A: 

An interesting article by Bram Moolenaar himself: Seven habits of effective text editing.

Paolo Tedesco
There is a video of Bram's presentation at Google of this topic here: http://video.google.com/videoplay?docid=2538831956647446078.
Pierre-Antoine LaFayette
+14  A: 

Here are some awesome screencasts that should give you an idea of what to learn next. There are also videos for intermediate and advanced topics, but the novice are in fact the most important.

Also, when I felt that I was stagnating and not really learning "the Vim way", I chose to disable arrow keys in both normal and insert mode. This forces you to use ESC to get somewhere, and makes you think more Vim-like. Ultimately, I enabled arrow keys again in insert mode, but I hardly ever use them. There are, most often, better ways to get around.

map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>

And especially

imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
Sarah
I like the idea of disabling the arrow keys, it's a nice way to force yourself to stop using them.
Idan K
It worked very well for me, but the first few days were extremely frustrating. Once you get used to it though, and throw the habit of moving around TOO much in insert mode, I recommend reenabling the imaps.
Sarah
These screencasts were awesome. Thanks for pointing out.
Mert Nuhoglu
Disabling arrow keys is AWESOME idea, I'm doing it right now.
gorsky
A: 

1- read this

2- if you use a rss reader subscribe to these pages

page 1

page 2

ali
A: 

I take a look at this list of Best of VIM Tips every now and then and I still pick up new tricks on a regular basis.

Brian Rasmussen
+1  A: 

Remapping/disabling the arrow keys as has been suggested is a great way to force yourself not to use them.

Another thing to consider: if hitting Esc on your keyboard is at all uncomfortable you might wish to remap Caps Lock to Esc in your OS. For me this was a hugely helpful step, as Esc is an awkward reach on my KB and that was another obstacle that kept me in Insert mode (as it was hard to get out). Having Esc on Caps Lock makes it a tiny reach and jumping in and out of Insert mode is very fast.

For learning advanced stuff in Vim the best resource is the :help, but for getting the basics down you just need to do it; it's muscle memory more than anything. You say you know search. Consciously use it as a navigation tool. The searches [/, ?] and the inline char based searches [f, F, t, T] are some of the key Vim nav tools. Just use them; comboed with the disabled cursor keys you'll be navigating on muscle memory alone in no time.

Text Objects. Easily one of the best features of the editor. This is the other thing to immediately consciously practice. Things like 'yiw', 'dit', etc. are so powerful and fast; learning and making use of them alone will make you feel like a Vim user.

Once you've got text objects and basic navigation down, then it's time to move on to reading and learning from the :help regularly and scouring the web for awesome plugins. Seriously, you can use Vim for years and have an "ah ha!" moment accidentally stumbling on some obscure tidbit in the :help you'd never known.

numbers1311407
A: 

http://www.vi-improved.org/tutorial.php <-- you should read and flowing this chat, it's very useful for beginner. Happy vimmer

James