开发者

Becoming better at Vim [closed]

开发者 https://www.devze.com 2022-12-23 01:21 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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 comfort开发者_运维百科able with complicated search/replace patterns).

  • How should I go about learning more?
  • What resources would people recommend?


"Why, oh WHY, do those #?@! nutheads use vi?" is a nice introduction to "the Vim way", especially about text objects which are one of the most defining features of Vim.


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 ones 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 is, 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>


  1. type vimtutor on the command line
  2. go into vim, type :help or <F1>
  3. subscribe to mailing list
  4. official vim docs


Two more tips:

  • Use Vim for editing everything (email, web forms, code, ...). When something feels slow, there is probably a quicker way to do it. :helpgrep is your friend.

  • Head over to http://vimgolf.com/ and compete. I've learned many tips and tricks that way. [Disclaimer: No responsibility is accepted for the long periods of time that "go missing" while competing at VimGolf].


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


This is how I've learned Vim (and a bunch of other things). It's pretty easy.

Browse the help documents and find a command for something you do all the time. Delete a whole word for example. Make it a point to remember this.

Now, the next time you find yourself hitting 'xxxxx' to delete a word, stop, put it back and use the new command. Look it up if you have to. So instead of hitting 'xxxxxx' you go back and hit 'dw'.

Do this over and over, it'll be slow at first but eventually it will stick.

Once you have that command down start at the top. Find another command for an action you do all the time...

You would be surprised how fast you can pick up new commands and techniques this way.


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.


See this thread: What is your most productive shortcut with Vim?

Especially the first answer.


Read Hacking Vim: A Cookbook to Get the Most Out of the Latest VIM Editor.


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.


I made this game to help my nephew learn, but it only works on Firefox and Chrome >.< http://kikuchiyo.org

For now, it just deals with movement and entering insert mode. Beta version allows you to attack enemies with light-saber, 'i' to the left, and 'a' to the right :P

Keep trying to learn Vim, it's worth the effort!

:)


Learning the vi and vim editors.


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.


the way I stopped using the arrow keys was not disabling them (I still use them in Insert mode) but if you think about it if you want to go right use your pinky finger which is the l key, go left Index finger the h key, & ring finger up ("ring up") the k key & "pick down" the j key.

So first of the four digits on your hand (forget about the thumb) the Index one is leftmost & the Pinky is rightmost. Use the expression "ring up" as in telephone call for up with your ring finger & the middle finger has nowhere else to go but down.

It also helps a lot I found to forget about what the keys are named (h, j, k, l). There isn't a good mnemonic for remembering them that way that I've found & there's not too many mappings using those keys either.


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.


101 Hacks to Make You Fast and Productive in the Vim Editor… Guaranteed or this series: Vi Vim Tips and Tricks


I think videos are very helpful in learning.

  1. Derek Wyatt's on vimeo
  2. vimcasts


1- read this

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

page 1

page 2


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

0

精彩评论

暂无评论...
验证码 换一张
取 消