5 ms·
A Starting Guide to VIM from Textmate
- powdahound 16y agoI think the the Command-T plugin for vim is one of the most helpful things when switching from TextMate: https://wincent.com/products/command-t https://wincent.com/products/command-t
- dfischer 16y agoYes, I think I use this more than anything in my workflow.
- devdas 16y agoThe snipmate plugin at http://www.vim.org/scripts/script.php?script_id=2540 http://www.vim.org/scripts/script.php?script_id=2540 may be useful for other textmate users. As a non Textmate user (I use vim), I have no idea of how well it would map to their Textmate experience.
- sudonim 16y agoI used to get stuck in vim when logging in to linux servers. The key things to know for any newbie... :q i ESC :w After I learned those, I've really come to love Vim. I imagine I'd need to learn about 50 more commands before I could be really well versed. What are some other important things to know?
- bradleyland 16y agoLearning to exit, insert, and save the file is about as minimal a text editor skill set I can imagine. You should definitely start out by running through vimtutor a few times. The vim help is also really good. The author also provides a good list of links at the bottom of the article.
- Dobbs 16y agohjkl for moving around. I and A insert beginning/end of line. 0 and $ go to the beginning/end of line without entering insert mode. :%!command -- Runs the entire document through the command. If you use visual mode and then press ':!command' and it will run the selection through the command specified. Super useful for sorting a list. Also ctrl+[ is equivalent to esc. If you rebind caps to ctrl you can easily hit escape and other commands like ^d, ^u (page down and up).
- dhimes 16y ago0 and $ go to the beginning/end of line without entering insert mode You might find ^ more useful than 0 for indented code as it takes you to the beginning of the text on the line (like the regexp).
- dfischer 16y agoGreat tip! I will be using this one.
- burgerbrain 16y agoIf your aim is to indent/de-indent text, try the > and < commands (in normal mode). I also find that selecting large blocks of text then using the = command to autoindent everything is exceedingly useful.
- dhimes 16y agodo you know how to highlight a block then double-indent? I can't make that work. With a block highlighted, I only know how to indent one ts at a time (then re-hightlight, etc.).
- ollysb 16y agoYou can use the universal "repeat last action" command: just hit . You can hit . as many times as you like and it will keep indenting.
- gurraman 16y agoI started writing the basic commands in a comment, but it got kind of long. You'd best look at a reference. http://tnerual.eriogerg.free.fr/vimqrc.html http://tnerual.eriogerg.free.fr/vimqrc.html http://www.pixelbeat.org/vim.tips.html http://www.pixelbeat.org/vim.tips.html http://www.rayninfo.co.uk/vimtips.html http://www.rayninfo.co.uk/vimtips.html I'd start with looking at commands that allow you to quickly move around in buffers first (/, f, t, w, e, b etc). Then start combining those with actions (ct", dw etc). Then "timesavers" such as macros and built-in conveniences (q, gqq, marks etc). The rest will come to you.
- wyclif 16y agoPython and vim: Two great tastes that go together (slides): http://www.tummy.com/Community/Presentations/vimpython-20070225/vim.html http://www.tummy.com/Community/Presentations/vimpython-20070...
- sudonim 16y agoThanks. Learning keyboard controls can be daunting. Your advice on where to start is much appreciated.
- hiteshiitk 16y agoJust print this http://www.viemu.com/vi-vim-cheat-sheet.gif http://www.viemu.com/vi-vim-cheat-sheet.gif out and stick it to your side board.
- 5teev 16y agoOne thing I do all the time is making macros on the fly for repetitive edits with :map. E.g., switch the current and next line :map * ddp Then type * in command mode to execute the steps. And if you mangle your file beyond hope with out of control macros, there's always u to undo and :q! to quit without saving.
- crazydiamond 16y agoAre you not aware that '*' (asterisk) searches for the next occurrence of the word under the cursor. That's one key i just can't live without. '#' (hash) does the reverse. Why not do a 'qq' to record your macro as 'q' and @q to replay it.
- 5teev 16y agoIt was an arbitrary choice for an example. Obviously one would choose a key not being used for anything else. (This choice can also vary from session to session, depending on the task at hand.)
- eeperson 16y agoProbably the most useful commands that aren't mentioned in most tutorials are: ctrl-[ can be used in place of ESC . repeats the last edit
- rbonvall 16y agoWhen you are experimenting, u (undo) and Ctrl+R (redo) are invaluable.
- zkirill 16y agoMy favorite VIM color scheme. http://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wombat/ http://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wom... With Monaco 13 typeface it's bliss.
- pyre 16y agoColorschemes that use italics are hit-or-miss for me. Sometimes I prefer to use Terminus which doesn't have an italic typeface, but vim will try and emulate one horribly. (Or when using DejaVu Sans Mono at 9pt (?) because the lowercase 'd' has it's tall part cut off when in italics causing it to look like an 'a')
- trafficlight 16y agohttp://vimcasts.org/ http://vimcasts.org/ has some excellent howto videos on Vim.
- spacemanaki 16y agoAnd he's writing a book on mastering Vim. "Vim’s documentation reads like a dictionary; I propose to write a phrasebook."
- bphogan 16y agoI used to use VIm for years before I got my mac, and I've been moving back to it recently. One thing I'm surprised nobody ever mentions is the ! command. If I'm working on a file and I want to, say, commit my work, I can do :!git commit -a -m "committing my changes" I used to do this a lot when working with Oracle and Bash. It's much quicker than opening another terminal for one-off commands.
- matwood 16y agoYou can always use fugitive which wraps many git commands into vim plugin: http://www.vim.org/scripts/script.php?script_id=2975 http://www.vim.org/scripts/script.php?script_id=2975
- bphogan 16y agoYes, that's really great too... I was just looking for an example that many people could relate to. :)
- jamesbritt 16y agoand :sh drops you into a shell Very handy.
- bsergean 16y agoThe cool thing with VIM is that it's the most consistent editor across all OS (including old Unices like HP-UX where the Meta key for emacs was screwed up sometimes), windows, etc ... and the next step is set -o vi or bindkey -v to get vi mode in your shell.
- deleted 16y ago[deleted]
- frb 16y agoLately I've noticed that more and more TextMate users are switching (back) to VIM. For years TextMate has been really popular, but now it looks as it's losing more and more users. Would be interesting to know why. What made you switch from TextMate to VIM?
- lenni 16y agoI switched to Vim because to me it seems that TM2 is vapourware. I know Allan is trying to get it right with his second go but he is so coy about any sort of details that I lost interest in it.
- spacemanaki 16y agoI'm being pedantic but, isn't it "Vim" not "VIM"? I seem to remember seeing something like a usage suggestion on the site but can't find it. It just looks silly to me, like when people write "LISP."
- frb 16y agoAlthough I've seen people "Vim", "VIM" and "vim" I never really thought about what the correct spelling is. Most times I went with "VIM" since I always thought of it as acronym for "Vi IMproved". But I think you're right with "Vim", since even on vim.org it's spelled like that.
- zenshade 16y agoOne thing that can be a negative irritant for new users is how far the esc key is and how often they have to reach for it. Vi wasn't designed that way. It was designed for keyboards that had esc where the caps lock key is on modern keyboards. One solution is to map caps lock to the esc key. Another solution, the one I prefer, is to map ii instead. This can be done with the following in the .vimrc file: imap <silent> ii <Esc>:let &insermode=0<CR> This doesn't work so well if you are frequently editing files on multiple servers you can't edit the .vimrc file on. But for your local environment it'll make going in and out of insert mode a lot more efficient. I'm dead used to using ii now so I'm probably not going to switch, but others have pointed out kk may be a better choice, due to greater distance between keystrokes/mode. Indeed, about one in ten times I hit ii when I don't need to.