What are the most-used vim commands/keypresses?

前端 未结 10 935
长发绾君心
长发绾君心 2020-12-22 14:22

I\'m a Ruby programming trying to switch from Textmate to MacVim, and I\'m having trouble wading through the gargantuan lists of things you can do in VIM and all of the keyp

相关标签:
10条回答
  • 2020-12-22 15:00

    Go to Efficient Editing with vim and learn what you need to get started. Not everything on that page is essential starting off, so cherry pick what you want.

    From there, use vim for everything. "hjkl", "y", and "p" will get you a long way, even if it's not the most efficient way. When you come up against a task for which you don't know the magic key to do it efficiently (or at all), and you find yourself doing it more than a few times, go look it up. Little by little it will become second nature.

    I found vim daunting many moons ago (back when it didn't have the "m" on the end), but it only took about a week of steady use to get efficient. I still find it the quickest editor in which to get stuff done.

    0 讨论(0)
  • 2020-12-22 15:01

    Have you run through Vim's built-in tutorial? If not, drop to the command-line and type vimtutor. It's a great way to learn the initial commands.

    Vim has an incredible amount of flexibility and power and, if you're like most vim users, you'll learn a lot of new commands and forget old ones, then relearn them. The built-in help is good and worthy of periodic browsing to learn new stuff.

    There are several good FAQs and cheatsheets for vim on the internet. I'd recommend searching for vim + faq and vim + cheatsheet. Cheat-Sheets.org#vim is a good source, as is Vim Tips wiki.

    0 讨论(0)
  • 2020-12-22 15:03

    @Greg Hewgill's cheatsheet is very good. I started my switch from TextMate a few months ago. Now I'm as productive as I was with TM and constantly amazed by Vim's power.

    Here is how I switched. Maybe it can be useful to you.

    Grosso modo, I don't think it's a good idea to do a radical switch. Vim is very different and it's best to go progressively.

    And to answer your subquestion, yes, I use all of iaIAoO everyday to enter insert mode. It certainly seems weird at first but you don't really think about it after a while.

    Some commands incredibly useful for any programming related tasks:

    • r and R to replace characters
    • <C-a> and <C-x>to increase and decrease numbers
    • cit to change the content of an HTML tag, and its variants (cat, dit, dat, ci(, etc.)
    • <C-x><C-o> (mapped to ,,) for omnicompletion
    • visual block selection with <C-v>
    • and so on…

    Once you are accustomed to the Vim way it becomes really hard to not hit o or x all the time when editing text in some other editor or textfield.

    0 讨论(0)
  • 2020-12-22 15:03

    Put this in your .bashrc to open vim with last edited file at last edited line

    alias vil="vim  +\"'\"0"
    
    0 讨论(0)
提交回复
热议问题