6 ms·
Ask HN: What's the best way to get started with Vi(m)
The title says it all. It's one of the things I've been meaning to do, but never quite did. Any suggestions? I'm a TextMate power user currently.
- derwiki 16y agoType `vimtutor` on your command line and hit enter.
- sophacles 16y agoThen spend a week doing as much as possible from within vim. You will start to get the basic hang of it. Then as you want to do other things, assume vim can do them for you and try and figure out how. #vim on freenode is good for this, although much of the help comes in the form of :he X. This means, read the documentation, the topic keyword is x. You literally type that into the editor command line :) The vim documentation is very good -- in fact just reading a few things extra every time you use vim is a good idea. A final note: I have been using vim for my main editor for years now, and still learn new stuff all the time. Playing with new scripts, finding new bits of workflow, and getting really fast at it all take time. This is natural. I try and pick a couple new things a week an use them. Sometimes I will then forget about them for weeks, months or years because I think they are useless, but "rediscover" them only to use them all the time. Its actually quite fun.
- prog 16y agoThats how I started. Following this I also made it a point to read at least a little vim documentation (:h) every day. Its very detailed and helpful. There is also the Vim book[1] by Steve Oualline which is also available free as a PDF. Reading Vim tips[2] was also something that I found useful. [1] http://www.vim.org/docs.php http://www.vim.org/docs.php [2] http://vim.wikia.com/wiki/Best_Vim_Tips http://vim.wikia.com/wiki/Best_Vim_Tips
- Madhav_ 16y agoin addition, this is a pretty good guide. http://www.ibm.com/developerworks/edu/l-dw-linuxvi-i.html http://www.ibm.com/developerworks/edu/l-dw-linuxvi-i.html
- wyclif 16y agoThat's the best tip of all. Ask yourself this question: "Can I walk through all the vimtutor examples without thinking too much?" If you can't, there is probably stuff in there you should learn. Make sure you know what an operator is, and what insert mode does. Listen to vimtutor when it tells you to learn by doing, not by trying to memorize everything in the tutorial. I learned by doing vimtutor over and over again until I could complete it without referring to help. If I forgot commands, I'd start over completely at the beginning and progress as far as I could until I had to start over to review. Do this a dozen times or so and soon you'll have basic facility. Also, use vim for everything, not just code. Use it for email, writing projects, file management, and explore what else it can do for you.
- mbenjaminsmith 16y agoAssuming you're on Mac you'll need to set up a decent .vimrc to enable syntax highlighting, indentation and some other bits. Vim is a different beast depending on how it's set up. The built in tutorial is a decent place to start. I think that's the only thing I did apart from editing code. It takes a while to get over the hump but it's worth it. I also suggest remapping your CAPS LOCK key to ESC. PCKeyboard Hack is free and simple to set up for that purpose. I've never liked the role of ESC in vi. It's too far away from the home keys. If you learn to love the efficiency, I'd suggest looking at Komodo Edit or another editor that has vim key mappings. I prefer Komodo because it's vim plus code completion (I'm not aware of a vim solution for that) and a bunch of other bits that will save time.
- nash 16y agoNot sure what features komodo has for completion, but between the built in omni-completion in vim 7, it's pretty powerful which will complete on symbols in all loaded files and in things like header files. That's activated by Control-X Control-O. Control-P or Control-N in insert mode. There are various plugins available to make it smarter for C++ and other languages (so it only searches in appropriate namespaces and the like).
- samratjp 16y agoI switch between vim and textmate. My favorite textmate/vim feature is column select - in vim, its ctrl+v (http://sethmason.com/2007/09/27/vim-tip-select-column.html http://sethmason.com/2007/09/27/vim-tip-select-column.html) in textmate it's option+click. Also, fwiw, Macvim may help retain vim usage.
- andrewljohnson 16y agoType this into your terminal: emacs
- derwiki 16y agoDo people ever get into serious arguments about using one or the other? At work we jokingly take jabs at the other camp, but that's more making fun of the fact that it's been such a hyped up feud.
- sophacles 16y agoI've seen it. It usually is the result of being trolled. The "troll" user of software A starts poking at the user of software B in a way that on the surface looks like an editor joke, but is actually about hte person. Something like "this code looks like it was written in X" or "how can an X user have completed bug #11". After a while it can get under the skin, but if the target is not paying enough attention, or is you know, working, the result can be a full on editor war.
- jimmyjim 16y agoOn a more serious note, do please feel free to give any and all helpful advice on how to get started with emacs. I'm okay with vim, I've been using it more and less for about 2 years, but emacs has always seemed more esoteric and I never did quite get the hang of it.
- leif 16y agoGet a friend that uses it well and will be nearby (physically) for a few months. I didn't learn until I spent a summer with Slava (coffeemug) at my side willing to answer questions. Find ways to do as much as you can of what you normally do with your computer in emacs. If you use IRC a lot, use erc. If you use email a lot, try out gnus or rmail. Don't try to replace your web browser with w3m, that's just stupid and you'll hate it. Also, find a mode you really like. This will keep you using emacs whether you like it or not, until you really do like it. For me, it was gdb-mode. For most, it's one of the inferior repl modes (slime for lisp or clojure or whatever, ruby, python). I've heard good things about http://github.com/technomancy/emacs-starter-kit http://github.com/technomancy/emacs-starter-kit, but I've never tried it.
- samdk 16y agoI think with something like Vim it's best to get a grasp on the very basics (saving/opening documents, moving into and out of insert mode, navigating with hjkl) and then add one of two things at a time as you get comfortable with those. If you try to do everything at once you just end up getting overwhelmed. I didn't really start to like Vim until I started playing around with my .vimrc file. There were too many minor irritants and things I wanted changed. An Ask HN on the subject came in very handy: http://news.ycombinator.com/item?id=856051 http://news.ycombinator.com/item?id=856051 Mine (along with a few other minor customizations) is at http://github.com/samdk/vimconf/blob/master/dotvimrc http://github.com/samdk/vimconf/blob/master/dotvimrc if you'd like to take a look. Some other good resources: http://dotfiles.org/.vimrc http://dotfiles.org/.vimrc http://www.vi-improved.org/vimrc.php http://www.vi-improved.org/vimrc.php
- jraines 16y agoCheck out vimcasts.org. The guy who makes them even occasionally refers to how to do things in vim that he likes in TextMate.
- markkoberlein 16y agoThis is the cheat sheet that I used to get started: http://home.uchicago.edu/~gan/file/vim.pdf http://home.uchicago.edu/~gan/file/vim.pdf Learn the basics first: 1. Basic movement (h l k j) 2. Insertion mode (i), deletion (x), selections/visual Mode (v), copying/yank (y), pasting/put (p), and exit insertion mode (esc) Once you learn those the rest is pretty easy to pick up. I should warn you though, once you get used to the key commands it's hard to go back to another editor.
- grayrest 16y agoI've always thought that the f and t motions along with I and A to switch to insert mode, and . (repeat) should be included in the basic motions and text objects should be the next step. They're relatively simple to remember and you can string them together to accomplish a lot more than the character-wise to word-wise motion progression I've seen in most vim intros.
- philwelch 16y agoAttach this to a visible surface near your desk: http://r00tsecurity.org/db/cheat-sheets/SOFTWARE/Vi/vi-vim-cheat-sheet.gif http://r00tsecurity.org/db/cheat-sheets/SOFTWARE/Vi/vi-vim-c...
- yesimahuman 16y agoIMO the only thing you can do is to start writing real code and force yourself to use it. Honestly, the vim help stuff was almost useless to me at first because I would forget it as soon as I learned it, since I didn't understand the vi mindset. You will notice a big drop in productivity at first, but hopefully you should notice yourself getting faster in a week or so.
- nose 16y agoYou can borrow my vim cheat sheet tomorrow.
- th 16y agoTo become a vim power user, you will really need to understand how and why vim works the way it does and how you should think about editing while using vim. Once you have gone through some of the great tutorials on basic vim usage take a look at these: Stay out of insert mode: http://cloudhead.io/2010/04/24/staying-the-hell-out-of-insert-mode/ http://cloudhead.io/2010/04/24/staying-the-hell-out-of-inser... Good explanation of how vim commands are actually formulated (Stack Overflow answer): http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 http://stackoverflow.com/questions/1218390/what-is-your-most...
- pmccool 16y agoAs a long time vim user, I have to ask: what's the appeal?I use it because I already knew vi, and I knew vi because it was the one editor I could be confident of finding on any UNIX box. I'm curious: what's the motivation for learning it from scratch?
- whimsy 16y agoAs opposed to doing what? Using a GUI editor? Using emacs? vim is just as likely to be on any linux/os x box today as vi was to be on any UNIX box when you were learning vi, and it's still very powerful today.
- icco 16y agoI just started using it do code everything I do. Found other coders I know through IRC that know how to use it, and we traded tips. Over time I found my self becoming more and more efficient with it. vimtutor, as mentioned in other comments also works really well.
- ppereira 16y agoI started by learning ed from "The Unix Programming Environment", and then vi. By tackling vim directly, you may get swamped in the details.
- heresy 16y agoI learned Vim inside and out because it was the only Linux console editor at the time that did syntax highlighting, and it kind of stuck. Also, working in 80x50 with only the editor open for a couple of months kind of gets you into the mode :)
- saurabh 16y agoThe way I learn to use my tools is I start customizing them, thereby understanding how they work, how others use them and how I can utilize them. Look for .vimrc's of other hackers. I learn't many things just from the dotfiles.
- pkrumins 16y agoStart with hjkl and see where it takes you. :)
- jng 16y agoThis was my best answer to the question, written 4 years ago, hope it helps: http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial... I also prepare this write up answering "Why vi?": http://www.viemu.com/a-why-vi-vim.html http://www.viemu.com/a-why-vi-vim.html They've been on the HN front page a few times, too.
- wrinklz 16y agoUse the Vimperator firefox plugin, so you can exercise your Vim muscles while you browse the internet.
- ananthrk 16y agoIn addition to all the excellent suggestions here, I will also suggest reading the free book "A Byte of Vim" (http://www.swaroopch.com/notes/Vim_en:Table_of_Contents http://www.swaroopch.com/notes/Vim_en:Table_of_Contents). This is how the book introduces itself: "A Byte of Vim" is a book which aims to help you to learn how to use the Vim editor (version 7), even if all you know is how to use the computer keyboard. The first part of this book is meant for new users who want to understand what Vim is and learn how to use it. The second part of this book is for people who already know how to use Vim and want to learn about features that make Vim so powerful, such as windows and tabs, personal information management, making it a programmer's editor, how to extend Vim with your own plugins, and more.
- suren 16y agoByte of Vim is one of the Best technical writings for newbies and pros alike. I had a wonderful time reading it and the way I use vim after that has changed a lots!
- 687 16y agohttp://vim.runpaint.org/ http://vim.runpaint.org/ and seconding Vim wiki (http://vim.wikia.com/ http://vim.wikia.com/)
- ZeroGravitas 16y agoI found that being a touch-typist helped, since the concept of vim is to have your hands on the home row using letter keys rather than arrows or mice. (I happened to learn Dvorak but I'm sure Qwerty would have a similar impact on getting the most out of vim). Plus it's a transferable and generally recommended skill for programmers.
- genieyclo 16y agoI'm surprised no one has mentioned Derek Wyatt's excellent series of videos. See his blog page with links to his videos: http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice-tutorial-videos/ http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice... Or go to his Vimeo page where they all sit: http://vimeo.com/user1690209 http://vimeo.com/user1690209