Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Thursday, June 7, 2012

Tips On Getting Started With Vim

My primary text editor is Vim. I've got it installed on every nearly system that I use. It's a great editor, and it boosts my productivity by a considerable amount.

One major downside to Vim is that it is very difficult to learn. I've been using it for many years, and I have some advice for those getting started with Vim.

Go Through Vimtutor Multiple Times

I think that Vim is best learned by doing. Many of the major key bindings make sense and can easily be memorized ('i' is short for insert, 'a' is short for append, 'x' is delete), but getting proficient at Vim requires muscle memory.

Vim comes with a hands-on tutorial called Vimtutor. Here's how you can start it:

Windows: The installer adds a start-menu shortcut named 'Vim tutor' in the Vim <Version_Number> folder. If you're on Windows Vista or 7, just type 'vim tutor'.

Mac OSX and Linux: Type 'vimtutor' in a terminal window.

Vimtutor doesn't cover all aspects of vim (like recording what you type and playing it back), but it does a great job of going over the basics. If you go through the tutorial a few times, you should have a good grasp of the basics and should be ready to use it for most of your day-to-day text editing needs.

Consider Not Completely Switching to Using Vim At First

I think that, for many people out there, the best approach to switching to Vim is a gradual one. Productivity is bad when you first start using Vim because it behaves like no other text editor (except for VI and other VI-like editors).  If you have due dates to meet and bugs to fix, switching exclusively to Vim is probably a bad idea until you get used to the basics.

Don't Be Afraid To Give Up (And Try Again)

Vim is complicated and weird. It's my kind of text editor, but it is not for everyone.

If you've tried the first few vimtutor tutorials and still struggle getting through them, considering using another text editor for a while. Notepad++, gedit, and Sublime Text 2 are excellent text editors that don't require weeks and months of memorization to use. After taking a long break, you can always go back to Vim and try the tutorials again.

Thursday, May 24, 2012

Evil - An Emacs Mode for VI/Vim Users

Two years ago, I wrote an article that covered two packages (Vim-Mode and Vimpulse) that brought Vim-style modal editing to Emacs. Evil (extensible VI layer) has been introduced as a newer replacement for both packages.

Wednesday, March 31, 2010

Short Post - My Favorite Vim Tip

Vim is a tricky editor, and there are many tips for using it to its full potential. Out of the tips that I know, I have a favorite.

Place this in your vim config file:
imap jf <Esc>
Now you can press 'jf' instead of Escape to exit Insert mode. Feel free to remove 'jf' and insert anything you want in its place.

Related Tips

cmap jf <Esc>
Exactly like the above, only this works in Command-line mode.
" Don't put this in your Vim config
vmap jf <Esc>
This manages to break part of Visual mode. Specifically, pressing '$' while in Visual mode will select everything from the current position to the end of the NEXT LINE (instead of the current line). Replacing 'jf' with 'jj' seems to prevent this glitch, but it could cause another one. Visual mode seems like a delicate little flower, and it's best not to step on it.

I didn't come up with this

I first saw a version of this tip in an old version of the Vim thread on The Awful Forums, so credit goes to whoever wants it. The old Vim thread is currently stuck in that forum's members-only archives, so I can't provide a link to it. But here's a link to the latest Vim thread that may or may not work for you.

Tuesday, March 16, 2010

Emacs for Vim Users

05-24-2012: The two packages (Vimpulse and Vim-Mode) discussed in this post have been replaced (for the most part) by Evil. I wrote about Evil in this post. While writing the Evil post, I discovered that this article has false information. I did not know that typing ':q' in Vim actually quits the current window while keeping the buffer open.

Is your brain wired for Vim/VI key bindings? It takes a while to get used to modal editing, but it seems to take even longer to become accustomed to not being able to use VI keys in every program. Emacs doesn't use VI keys by default because it's Emacs. Why use Emacs when your brain is wired for VI? Packages like AUCTeX (LaTeX-editing mode) and js2-mode (awesome JavaScript mode) exist!

Want to learn how to bend Emacs to your Vim-powered will? All that junk is after the break.

Sunday, March 14, 2010

Using Project.tar.gz

Project.tar.gz (available here) is a plugin for the Vim text editor. It provides Vim users with a special window that allows quick access to a specific group of files. This special window is somewhat similar to Visual Studio’s Solution Explorer or Eclipse’s Project and Package Explorers.