views:

483

answers:

14

Hi,

I have started to do some programming using VIM.
I have very mixed feelings so far. On one side I do love the idea, on the other - it is just hard to remember everything.

So I took the approach of learning while actually doing some stuff (for Ruby on rails development).
Unfortunately there is no chance in hell for me to be more productive as in other "conventional" text editor for now. And it seems it will take quite a lot of time to get used to VIM.

I noticed, that I often don't use VIM navigation/search&replace abilities, but instead just move around as I would do in other editors.

I am trying hard pushing myself not to open anything in other editors except VIM so I can learn it.

But, honestly, yesterday I gave up and did my last 20 minutes of coding in GEdit.

UPDATE: I want to say why I gave - just because of I would finish what I need faster (it was veeeery late and it was not the best time for learning VIM). And indeed I did enjoy using VIM. But I always had the "there must a better way of doing this" feeling and spent a lot of time finding that way.

So my question wold be: how can I learn and start using VIM more productively from day to day provided that I want to do some real coding when learning?

Thanks,
Dmitriy.

+4  A: 

Why? Use whatever editor suits you best and makes you the most productive. I use vi for editing configuration files, because it's usually the quickest way to edit a few lines and then exit. For serious programming, it's either TextMate (ruby), Emacs (python or ruby on platforms without TextMate) or Xcode (objective-c).

calmh
Don't go there. Please. Vim vs. Emacs is too argumentive.
the_drow
He has a point though. If you don't get the hang of something after fighting it for some time, why cripple your productivity? Use the tools you're comfortable with. I don't think this answer was meant as the start of a Vim/Emacs flamewar.
musiKk
@the_drow I'm not going there, I'm saying use either or both, for whatever purpose they seem best for. You brought up the controversy.
calmh
+1 - Don't get caught up in the idea that [Real Programmers](http://xkcd.com/378/) have to use Vim or this or that. Real programmers deliver and get paid :P
LeguRi
Guys, I did enjoy coding in VIM. My problem is that I still don't know enough to be productive. So I gave up to just finish a piece of work as it was a late night :) (it would take me probably 30% more time in VIM).
Dmytrii Nagirniak
+2  A: 

I've heard very good things about SwaroopCH's Byte Of Vim book. Haven't gotten around to reading it myself yet, but his Byte Of Python book is definitely excellent.

PROGRAM_IX
I use Learning Vi adn Vim editors book which is pretty good. But the best boost I got is from PeepCode Smash Into vim.
Dmytrii Nagirniak
+4  A: 

Start using it when it makes sense : quick edits on config files, commit messages, README updates, etc...

The startup speed can difficult be beat.

When you get the hang of the basics, explore the help file if you think "there must be something in there for the task I need to do now". ...

Build the knowledge gradually.... step by step...

Until you find one day you do a lot of your editing in VIM or find that your toolchain is well integrated with Vim.

I personally use whichever works best, IntelliJ for Java, Emacs for clojure, Vim for perl and ruby scripts, Textmate when I am on the Mac. ...

Peter Tillemans
and then use it for everything. And then realize that you just put a series of 'j's in your Microsoft Word document because you're trying to go down a line ;)
espais
You spot me:`there must be something in there for the task I need to do now`. That is exactly how I feel. While coding I thought about it most of the time and indeed browsing book and searching Internet brought me to a good answers. So the time for actual editing right now is huge because I often try to figure out how to do something better way. I hope I'll learn more and more with time.
Dmytrii Nagirniak
I think the VimClojure addon is pretty sweet, but then I don't know emacs.
intuited
@Intuited: I tried it and the integration with nailgun is pretty sweet. Paredit is the reason I prefer emacs
Peter Tillemans
+3  A: 

I am trying hard pushing myself not to open anything in other editors except VIM so I can learn it. But, honestly, yesterday I gave up and did my last 20 minutes of coding in GEdit.

Developer should be comfortable with the environment he works with. That's why there are lots of editors developed by the developers for the developers.

As long as the editor does what you want, the way you want, it is all fine: editor is just a mean to do the work.

So my question wold be: how can I learn and start using VIM more productively from day to day provided that I want to do some real coding when learning?

For the VIM, unfortunately, my recommendation would be to spend several days with it without doing any real work, but simply learning. It took me about two days to get to know the basic functions required for the efficient editing. I knew that editor would play important role in my daily work that's why I have invested close to the week of my spare time to learn both VIM and Emacs.

My ex-colleague also kept a VIM cheat sheet as his desktop wallpaper. Helped in the beginning.

Dummy00001
PeepCode's Smash Into VIM got me started pretty fast. I now keep Learning VI and VIM book near me. But I am not sure if I can learn VIM properly not doing a real coding.
Dmytrii Nagirniak
IMO books do not help to start with vi/VIM. One has to learn the basics: moving around, select/copy/paste, search/replace. Until the basics were covered, I have used [nano](http://www.nano-editor.org/). In my case, the VIM adoption was also helped by my knowledge of shell and the fact that I'm touch typist. Help system (`:h`) is excellent too and the [Vim Wiki](http://vim.wikia.com/wiki/Vim_Tips_Wiki) is very helpful. But if you do not like VIM after few weeks of trying, then do not force yourself and use whatever you like better.
Dummy00001
A: 

vim takes a lot of time to get used to and actually be productive with this is how i look at it: suppose your productivity index is anywhere between 1 and 10 when you start using an other editor, your productivity index is like 6, and can go up to 8. when you start using vim, your productivity is like 2, but you can go up to as high as 10. it just takes time.

efrat
+6  A: 

I use Gvim (the GUI mode). If you forgot the key sequence for some action you can invoke it through the GUI. For most actions you can also see the necessary keys, so that Gvim can also serve as a quick reference for Vim.

Off course a different text editor will not magically make you more productive. But if you like to use keyboard shortcuts on the mainstream editors, you'll like Vim because you can trigger fairly powerful actions with a few keystrokes.

I personally don't like Vim, I prefer mainstream editors. But Vim has REST syntax coloring, and I found it perfectly usable after about a week.

Eike
+1 for GVim. I use GVim quite often when i work with local files and it allows to do a lot of actions similar to other editors (for example cut/copy and paste) which helps in the beginning.
dbemerlin
+1 for menus providing discovery/reminder for keyboard shortcuts.
Roger Pate
+2  A: 

This might help: Why, oh WHY, do those #?@! nutheads use vi?

Dan Dyer
Awesome article. Thanks. I would not give up if I would read before. Now I have more energy to embrace VIM again :)
Dmytrii Nagirniak
+8  A: 

Keep the following in mind. While there are physical limits to the speed of your fingers, there seem to be few limits on the processing that your brain can perform. Therefore, the time you invest in learning vi(m)'s keyboard editing commands and shortcuts will be paid back handsomely over time as the speed with which you edit improves breaking the physical speed limits you would encounter when using a traditional editor. For instance, to delete the next five words in vi(m) you type 5dw and to insert 50 * characters you type 50i* ESC.

You can begin using vi(m) after learning very few commands: basic movement, inserting, changing, deleting, opening a new line, and saving a document. Coupling these commands together produces powerful combinations. As you master these, you'll be looking for more.

Print a vi reference sheet (like this, or this or this more extensive list), and keep it near you at all times.

Diomidis Spinellis
Thanks. I should always keep in mind `the time you invest in learning vi(m) .... will be paid back handsomely over time`.And thanks for the links with!
Dmytrii Nagirniak
+5  A: 

I'm more static typed languages guy and here is my story:

For me VIM was all about hjkl movement in normal mode + intert mode. I've found it so efficient that I wanted to have it all the time, everywhere.

Then I started to read cheatsheets from time to time and picking up the best gestures to remember (somehow sorted from most commonly useful to less useful ones): b, w, x, gj, gk, gg, G, numberg, *, #, %, f/t/F/T, /, >>, <<, =, v then mark with j/k, <</=/>>.

Then I started to write Makefiles to everything and configured Vim to impretet it. So I do :mak and I'm right at the line that error was found.

Then autocompletion happened (binded to TAB).

Then natural language checking z=.

Then I've written a wrappers for switching buffers. Opening them with :e filename.c and then doing Ctrl+l, Ctrl+h.

I have my config publicly available in git archive here: http://github.com/dpc/vim-config

dpc.ucore.info
+3  A: 

Learn at your rhythm. I think you should start mastering the basics:

  • modes: command, normal and visual
  • the commands: paste, yank, delete.

Then you can improve these knowledges:

  • learn some useful commands in command mode (list buffers, substitution)
  • learn to move faster (beginning/end of the word/line/file)
  • search/substitute a pattern
  • Look at people's vim config and customize yours

While doing this, always keep a vim cheat sheet near you. The basics commands are easy to remember (d for delete, p for paste, y for yank, i for insert, a for append, ...).

Learn progressively and stay simple.

Taurus Olson
I have got the PeepCode's Smash into Vim series and using its config (slightly changed). Learning at my rhythm is a good suggestion. Thanks.
Dmytrii Nagirniak
+1  A: 

How about books?

These ones are excellent:

  1. Learning the vi and Vim Editors

  2. VI Editor Pocket Reference

And after all, so what - so you don't work with vim. What is the big added value for vim, which worth the difficulty of learning it?

rursw1
I am working with the 1st one. For me it is not about the big added value (though it is very important), but rather knowing something different from what conventionally is accepted.Much like I am learning Ruby (dynamic language) after C#.
Dmytrii Nagirniak
+2  A: 

Here's some novel advice from Yehuda Katz, a core member of the Ruby on Rails team who recently switched to Vim: Try using it exactly the same as you would any other editor at first so you can keep being productive. Maybe this means continuing to use the arrow keys or *gasp* mouse at first. Don't try to learn all the Vim ways at once. Rather, let them come slowly and naturally.

The full article is a great read:

Everyone Who Tried to Convince Me to use Vim was Wrong

Additionally, try using vi key bindings in other applications. If your shell supports vi movement, use that. For web browsing, try the phenomenal Vimperator Firefox plugin.

michaelmichael
How on hell I could miss his article...Thanks for the nice advice. Currently I use Visual Studio a lot so I guess I can try VIM for it as well.When I navigate in the VIM "the conventional" it always feels dirty for me. Probably for now I just have to go over it. Hopefully later it won't become a habbit.
Dmytrii Nagirniak
+1  A: 

Here is how I learnt when I switched from Windows to Linux:

1) I printed out the vim quick reference card(pdf) and kept it next to my keyboard at all times.

2) I started off with gvim and used the easy mode (gvim -y or evim). This makes vim behave like a regular editor - it is always in insert mode, and the keys are mapped to work like a regular CUA editor (e.g. CTRL-X/C/V for cut/copy/paste). You can still access all the vim functionality with CTRL-o to enter a single Vim command, then it will go back to insert mode.

After a while I got fed up with using CTRL-o or the menus all the time, and switched to proper Vim mode. I have not looked back since then and now use Vim for everything, even on Windows. I even use Vimperator on FireFox.

It is also worth taking a look at Cream - this is like vim easy mode on steroids.

If you find that you comfortable using evim or cream then there is no reason that you have to go all the way switch to normal vim mode, whatever vim purists may say. You should aim to become a master of your tools, not a slave to them.

Dave Kirby
A: 

Perhaps some Easter Eggs would help you get started on the right foot. Try the following and enjoy the wonderful world of open source tradition and legacy of contained silliness :)

  • :help 42
  • :help holy-grail
  • :help!
  • :help map-modes (see comment below the table about :nunmap)
  • :help UserGettingBored
  • :help spoon
  • :help showmatch (read the note)
  • :Ni!

(know more: visit vim.org)

konzepz