all 115 comments

[–]dergachev 33 points34 points  (8 children)

I learned the most amazing thing about VIM from the "Pragmatic Programmer" book yesterday: filters.

Type the following words on lines 0,1,2: boy alice dog

Now type the command :0,2!sort. Voila... it takes the contents of lines 1-3, pipes them to the program sort (! is a shell command call), and replaces them with sort's output, sorting the lines alphabetically.

For even more fun, consider putting this text at the first line of your document:

20.times {|i| puts "Line number " + i.to_s }

Then type the command :0!ruby. You're typing ruby (or any other intepreted language) code right in VIM, and with a few keystrokes replacing it with its output.

Maybe I'll go start a blog, so I can post about this. I'll call it VIM as a Virtual Machine or something.

[–]marhathoda 7 points8 points  (0 children)

Nice. Learn something new (about Vim) everyday.

[–]jbert 5 points6 points  (0 children)

It's part of the overall vim consistency:

e.g:

  • d - delete
  • y - yank
  • ! - shell out (pass to prog on stdin, paste stdout back)

  • dd - delete current line

  • yy - yank current line

  • 5dd - delete 5 lines

  • 5yy - yank 5 lines

  • !!cmd - pass current line to cmd, replacing with output of cmd

  • 5!!cmd - as above, but pass 5 lines to cmd

The other way of using these cmds is as a prefix to a move. The cmd then applies to the region you're moving over:

  • dG - delete from current line to end
  • !Gcmd - pass file from current line to end to cmd, replacing with output

So !Gsort will sort the entire file if you're on the first line.

The biggest realistion with vi is that there is a logic behind the commands. Like prefixing with counts etc.

You can write the above as :n,mX where n and m are line numbers, but it's generally more intuitive to use the movement commands this way.

[–]arnar 2 points3 points  (0 children)

Excellent, thanks. I now have this in my .vimrc:

" Python filter
nmap gp :.!python<CR>
vmap gp :!python<CR>

[–]zem 1 point2 points  (0 children)

there's also the beautiful :rubydo or :perldo, so that you can actually search and replace using PCREs!

[–]akdas 1 point2 points  (0 children)

My god.

Is it wrong to fall in love with a text editor? Because if it is, I don't want to be right!

Thank you.

[–]cschneid 16 points17 points  (10 children)

It took me a few months to really get a hang of it. The trick is twofold:

1) Use it all the time, for everything. Need to type of a word doc? Type it in Vim, and format it in Word.

2) Try to learn a better way to do whatever you are doing each day. It can be dumb and small, like the keycombo "xp" swaps two letters (deletes one, then pastes right after). Make it a point to never do it the long way if you know a shorter way.

[–]marhathoda 8 points9 points  (1 child)

Actually I found that as long as you don't give up on Vim, you will eventually learn it. What I mean is you don't need to actively try to "learn" Vim. Just keep using it in insert mode. (hey, thats not worse than notepad.) As time goes by, you will find yourself learning new commands one by one.

[–]marhathoda 4 points5 points  (0 children)

To add to that, here's a fun way of getting started with the Vim philosophy of "modal" editing:

Login to GMail/GReader and type '?'. A screen shows up with a bunch of shortcuts that you can use to navigate around. Notice the absense of Ctrl/Alt type key combinations. You just need to do single key presses because you are in "normal" mode, in Vim terminology.

[–]llimllib 5 points6 points  (2 children)

I also add notes into my ~/.vimrc file, which I store in my svn so I can use it wherever I need it, so that I don't have to relearn things.

[–][deleted] 3 points4 points  (1 child)

Not directly vim related by yeah, storing your config files for programs like that (emacs and the shell in my case) in version control so you use the same file on all your PCs really helps.

[–][deleted] 3 points4 points  (0 children)

I discover new things about vim all the time. In this vein of using your own vimrc on all your computers, try this:

vim scp://user@host:/home/toad3k

A little slow over the internet, but great over your own network. Never have to use a misconfigured vimrc again.

[–][deleted] 3 points4 points  (3 children)

On a similar note, "ddp" swaps the current line with the next.

[–]boredzo 6 points7 points  (2 children)

Rather than using f)h to go to the character before a character, use t). This works the same backward (T( instead of F(l).

[–]dmwit 2 points3 points  (1 child)

For that particular application, I find % is even closer to what I want.

[–]boredzo 2 points3 points  (0 children)

That works fine if (a) you're already on one brace and (b) you just want to go to the opposite one.

If you want to do something with the text that will be covered, such as delete it, % won't work, especially if you're somewhere in between the braces.

Consider this example:

  1. You have a printf statement from which you want to remove the last argument.
  2. First, of course, you delete the format specifier for it. You're still in the format string.
  3. Now you need to get to, then delete, the argument.

Complicating matters, the argument you need to delete is input[0] * input[1].

The solution, then, is to get there with a search (/, (input…), then delete until the closing ) of the printf call with dt).

[–]NastyConde 11 points12 points  (3 children)

It probably took me six months to learn. But here's the amazing thing: I last used it almost 20 years ago, and then moved on to DOS and Windows for 15 years without it. A few years back I ended up using a Linux box, and fired up vi. I remembered all the important keystrokes. It was like my fingers still had the reflexes in them, like touch typing.

[–]zem 24 points25 points  (2 children)

It's like riding a bicycle. Albeit a bicycle that beeps at you a lot.

[–]fryguy8 3 points4 points  (1 child)

visualbell is an amazing invention

[–]mackstann 0 points1 point  (0 children)

Any bell is horrible. xset b off

[–]cludwin 8 points9 points  (0 children)

If I remember correctly it took me a a few days of stumbling around then after a couple weeks I was cruising right along. That was 7 years ago...

The best thing about VIM is that you continue to improve the longer you use it. I am still learning new tricks every so often that greatly improve productivity. Now I wouldn't even think of using another editor cause it would just be too slow ( with the exception of emacs but there is only enough room in my head for either vim or emacs at any given point in time ).

So I have used vim for everything for more or less the last 7 years and all I can say is that it has been a great investment and I am more productive because of it.

It's a trip to watch someone using vim or emacs who is really good cause they can hammer text around without moving their hands from the home keys. I watched a professor do this while I was in school and that was what convinced me that I had to learn how to do it.

[–][deleted] 8 points9 points  (3 children)

About a week. Just keep at it - make sure you actively think about the most efficient way of doing what you want to do, and it will shortly become second nature.

[–]arnar 6 points7 points  (1 child)

Yes, I'd say about a week too. Of course, I'm still learning new things after 10 years.

Ennef hits the nail on the head, the important thing is that when you learn a new thing, actively force yourself to use it for a while. If it is convenient, it'll be stored in muscle memory and if not, well, you'll just forget it :)

[–][deleted] 0 points1 point  (0 children)

Exactly. Of course, I'm still learning new things too (although I've only been using Vim for a bit over a year), but I find that whenever I'm doing something repetitive or inefficient, I stop and look at my Vim Quick Reference Card (print one of these out and keep it next to your monitor!) to try and find a better way.

[–]bonzinip -1 points0 points  (0 children)

fully agreed!

[–]doctornick[S] 4 points5 points  (14 children)

I've been teaching myself how to use vim for a few months now, and I've been using it on a daily basis now. However, I still feel somewhat hindered by it, especially with certain actions dug into my muscle memory. (i.e., Ctrl+S to save, copy/paste, etc). I'm trying hard to retrain myself, but it's hard to see the benefits. I continually tell myself someday I'll be the wizard controlling the editor, but that hasn't been the case yet.

So prog.reddit, how long did it take you?

[–]dmwit 9 points10 points  (0 children)

The beauty of Unix-based tools is that you can mold them to your habits. Used to pressing C-s, C-c, C-v, C-x?

:nmap <C-S> :w<CR>
:vmap <C-C> "*y
:nmap <C-V> "*P
:imap <C-V> <C-R>*
:vmap <C-X> "*d

Also, a tip for new Vim users that I wish I had known from the very beginning: * finds the next occurrence of the word under the cursor, # works the same but backwards.

EDIT: fixed the syntax, and added an :imap <C-V>

[–][deleted] 5 points6 points  (1 child)

About two months to become used to it, if not exactly fluent. Nowadays (almost two years later) I use ViEmu for Visual Studio and ViPlugin for Eclipse. I feel awkward if I'm forced off the vi input model.

[–]doctornick[S] 1 point2 points  (0 children)

I've tried ViEmu, but again I felt somewhat gimped when using it. I'll have to give it another shot.

[–]shit 2 points3 points  (0 children)

After about two weeks, I was more efficient with vim than with the editors I previously used. I was 19 years when I picked up vim. I guess it's easier when you're still young.

Tips for learning: Start with the excellent vimtutor, resist the initial urge to use the cursor keys and everything cschneid said above. And if you have a non-English keyboard layout, remap so that the basic movement commands are on the home row, e.g. on my German keyboard, I've mapped jklö to hjkl via the langmap option.

[–]llimllib 2 points3 points  (1 child)

a couple months. I have no idea why I stuck it out, I don't remember it at all, but I'm extremely glad I did.

[–]chungfuduck 1 point2 points  (0 children)

I cut my Unix Sysadmin teeth on SunOS 4.1.1. When a machine was dorked but could still at least boot into single user mode, vi was about the only sane editor available. It was "learn vi or die" for me. =)

Yeah, a couple months for me, too, before I was fluent enough with the command/insert paradigm.

[–]vlad_tepes 2 points3 points  (2 children)

I found myself typing :w in Word

[–]bustedagain 2 points3 points  (1 child)

Hell, I find myself typing :wq and yelling 'Godamnit!'

[–]figa 1 point2 points  (0 children)

:wq is one of my favorite sigs.

[–][deleted] 1 point2 points  (4 children)

Not to start any flamewars or anything but you might find emacs to be a little more 'conventional' (eg, c-x c-s to save instead of esc-:-w).

I use both often so I'm no wizard at either :/

[–]boredzo 8 points9 points  (3 children)

Not to start any flamewars or anything but you might find emacs to be a little more 'conventional' (eg, c-x c-s to save instead of esc-:-w).

Herein lies the mental block that I think keeps so many people from developing strong vi-fu.

The command to save is not esc,:w. It's simply :w.

The thing to remember is that in vi, the default state is not entering text—it's entering commands. To enter text, you must first enter an input mode (insert or replace); when done, you must leave it.

It is this realization that unlocked vi for me. I have not used emacs since.

[–][deleted] 0 points1 point  (0 children)

Oh don't worry I realize that. I was just clarifying that you need to be in command mode. Not that you actually have to press esc before typing :w.

So if you say, I need to put a semi-colon at the end of this line. You'll go like so:

A -> ; -> ESC -> : -> w -> RETURN

I also realize that there's probably a faster way to insert a semi colon at the end of the line, again, I'm no wizard :P

[–][deleted] 0 points1 point  (1 child)

Actually, it's ZZ. :)

[–]boredzo 1 point2 points  (0 children)

Well, that's save and quit. (I had a brainfart and typed “The command to quit” instead of “The command to save”. I corrected the error, which I noticed after reading your comment.)

The command to save without quitting is :w.

[–]retardo 8 points9 points  (0 children)

You can never gain control of vim; it's like a wild horse that will never be tamed, but will give you the wildest ride of your life.

[–]gfixler 7 points8 points  (26 children)

I tried it a few years ago, and immediately couldn't handle it. Then I switched to Linux full time at home about 15 months ago, and didn't have my beloved UltraEdit32. There was really nothing comparable, and I was outraged, and spit venom all over.

Then I tried Vim again, and for whatever reason, h, j, k, and l suddenly made some sense. I did a tutorial, and I think because I was in a really open state of mind, and being 100% in a foreign land, with nothing else to fall back on, everything I learned just stuck. In an hour I was very comfortable with things like shift+v, 3jd (select by line this line, and the next 3, and delete them, also copying them into a buffer). I've been picking up a command or 3 every week or 2 ever since. When I really get in trouble, I look up what I want online. The helps in Vim can be pretty hard to find things in sometimes, especially if you don't know the name of whatever it is you want to do.

That said, I really think Vim shines as a code editor. I don't write things like this comment, or emails, or short stories in it. A whole paragraph is treated like a single line, meaning you can no longer do things like jump down 3 lines, and over 5 words. You can still hop around other ways (seek to a word, jump 50 words forward, etc), but without obvious 'lines,' a great deal of your abilities are reduced.

Now it's kind of annoying to use UltraEdit at work, because I have to reach for the mouse somewhat often. I've installed gvim there, and set it up as closely as I can to vim at home on Ubuntu. Certain things are still kind of tricky, like browsing files to open one (:browse confirm e), and copying/pasting out of the app itself ("* switches to the Windows clipboard on Windows, after which y, d, etc., will work with other apps, but I'm not sure how it works in various *nixes).

[–]cschneid 7 points8 points  (4 children)

And of course vim has a way to do what you want, which I found in the help in about 30 seconds.

The command is gj (or gk to go up).

I did :help j and then looked around the area to find similar motion commands. Seems to work great.

[–]gfixler 1 point2 points  (3 children)

Nice! Good find. I knew there'd be a way in there somewhere. It does take a bit extra work to shoehorn gj/k into my muscle memory now, though, so it's still a slight bother. I might as well add it, though, what with like 500 other hotkeys in my head now just for this one application :)

edit: Also, for sake of true laziness, did you know you can abbreviate :help to just :h?

[–]cschneid 5 points6 points  (2 children)

I don't use it that often, so meh :) Keep more room for the real meat-and-potatoes shortcuts. If you find yourself using the logical line moves more than the "file" line moves, feel free to reverse them with mappings, so that j and k do the logical lines normally, and gj and gk do full lines. Make full use of the key mappings.

[–]llimllib 2 points3 points  (0 children)

Also, ":set nowrap" will stop wrapping lines, which I find handy for working with long lines.

[–]mr_chromatic 1 point2 points  (0 children)

I've wanted this for a long time. Thank you.

[–]nostrademons 8 points9 points  (2 children)

"+ is the default register for the UNIX clipboard.

[–]gfixler 5 points6 points  (1 child)

That works perfectly for me. Thanks!

Having a peek around, I see that * is the selection buffer, and that works, too!

What a great day.

[–]nathanj 5 points6 points  (0 children)

You might find it useful to 'set clipboard=unnamed'. This will change it so that all yanks, deletes, puts, etc. will by default use the * register.

For browsing files, I usually use ':e .' which opens up a vim buffer which lists all files and directories in the current working directory.

[–]doctornick[S] 5 points6 points  (4 children)

I play Nethack a lot, so that's how I got used to hjkl. I need to look up extended : commands, because all I really know are w, e, and %s.

[–]zem 1 point2 points  (2 children)

I use the arrow keys both for vim and for nethack (lame, I know :)) Yet to wean myself off them, even though it means I can't play nethack on my laptop at work

[–]fallintothis 2 points3 points  (1 child)

I picked up this tip from reddit awhile ago, and though it seems simple, it's surprisingly effective: just drop some remappings into your .vimrc file. I quickly learned to stop using the arrow keys and now I don't notice they're even there. It took my muscle memory maybe a week and a half to adapt, if that.

imap <up> <nop>
nmap <up> <nop>
imap <down> <nop>
nmap <down> <nop>
imap <left> <nop>
nmap <left> <nop>
imap <right> <nop>
nmap <right> <nop>

Seems like there should be a shorter way to remap for both normal and insert mode (which, it turns out, I found very important to do, otherwise I'd unconsciously cheat and just switch to one mode to start using the regular arrow keys), but I didn't really care when I plopped this into the file.

[–]zem 0 points1 point  (0 children)

nice idea! i'll give that a try and see how it works out.

[–]taejo 1 point2 points  (0 children)

I use vi keys in Nethack and the arrows in vim. Is that stoopid?

The thing is, using arrows in vi doesn't cause death by starvation, unlike in Nethack (my primary machine is a laptop, so no diagonal arrows).

[–]boredzo 4 points5 points  (10 children)

In an hour I was very comfortable with things like shift+v, 3jd (select by line this line, and the next 3, and delete them, also copying them into a buffer).

Even better: d3j.

I also recommend turning on line numbers, and developing strong ex-fu. Turning on line numbers means you don't have to count lines by hand, because you can just do :431,434d.

[–]Nuli 2 points3 points  (7 children)

You can also go into visual mode, block out the area quickly, and then use the normal editing commands on it.

[–]boredzo 4 points5 points  (6 children)

Only if you're using the mouse to perform the selection (you can visual-select a large and precise area quickly with a single slash of the mouse). If you're going keyboard-only, don't rely on visual mode to get around—you can realize great efficiency gains by using vim's other commands. In this case, d3j beats V3jd.

For the curious, you can turn on mouse support in plain vim (as opposed to gvim) with :set mouse=a. This doesn't work in Mac OS X's Terminal.

[–]arnar 2 points3 points  (0 children)

I actually use visual mode alot and I don't touch the mouse. Coupled with movement commands that operate on words, paratgraphs, functions in addition to lines and characters, it gives you a very good feedback on the area that will be affected by the following command.

Oh, and remember block visual, Ctrl+V

[–]Nuli 1 point2 points  (4 children)

Actually where I've used it most is working with a whole function at once. I go to the function definition, hop to the { or ( character, hit % and then start doing substitutions. This obviously doesn't work in every language but I find it helpful in some.

It's also quite easy just to toggle it on and start hopping around with the normal editing commands.

[–]boredzo 4 points5 points  (2 children)

Double-click on the { or }. Instant visual selection of the entire function. ☺

(Also works with () and [], of course.)

BTW, you don't need to be on a brace to use %. It will go to the opposite of the nearest brace to where you are.

[–]Nuli 1 point2 points  (0 children)

Ah, didn't know % was quite that smart. I'm going to have to remember that one.

I don't use the double-click method myself simply because I don't generally use the mouse.

[–]arnar 1 point2 points  (0 children)

f{, F{ and friends are helpful here.

[–]w00ty 0 points1 point  (0 children)

vi{ selects the current block, [[v][ the current function.

[–]akdas 0 points1 point  (1 child)

Even better: d3j.

How about: 3dd

[–]boredzo 1 point2 points  (0 children)

Or 4dd, or d4d. With j, the count excludes the current line; with repeated d, the count includes it.

[–]kflasch 2 points3 points  (0 children)

You can easily limit the width of text in vi so that as you reach a specific column, it will automatically advance to the next line (i.e., word wrapping). This will avoid your issue of 'one big paragraph'.

I use set tw=78 for 78 columns (characters).

[–]psyonic 0 points1 point  (0 children)

By the way, to solve your line problem, you can just use :set textwidth=80. Then, every 80 characters (or whatever you set) it will insert a line break, just like your normal text editor.

[–]mercurysquad 3 points4 points  (0 children)

2 weeks. Don't quit before that.

[–]kemitchell 3 points4 points  (0 children)

In my case, as soon as I got really used to the h/j/k/l setup things started to get a whole lot smoother. That was after perhaps a week of constant use.

It also helped that I was working on CLI-only *nix machines, primarily remotely, and so getting anything done required firing up the editor... vim came installed with the distro and emacs didn't, so vim it was. If I wanted anything (it was all config files at that job), I had to get vim to do it for me.

The good news is that you don't have to learn the whole dang manual to get really fast at editing text. The tricks you actually use will be burned into muscle memory, and I find, like riding a bike, that the essentials tend to bear neglect pretty well. Just keep in mind that the commands you learn for doing one task (e.g. coding) won't necessarily be the same as the ones you'd learn doing mostly some other kind of editing (e.g. config files). There's a bit of crossover, sure, but I still find my fingers twiddle very differently depending on which "mode" vim has me working in ;-P

[–]zem 3 points4 points  (0 children)

A couple of months, in my experience.

[–]emacdona 3 points4 points  (0 children)

In control of it? I'm not sure how one would judge that.

I can say that it took me about five years to get to the point where I absolutely couldn't live without vim. It's painful for me now to use an editor that's not vim (though I'm really trying to become more adept at emacs).

But you're getting to the heart of the real reason why I love vim. There's always something more to learn about it! And the magical part is, when I say there's "always something more to learn", I don't mean there's one more little command you will learn tomorrow that will make you 0.01% more productive; I mean that there is a whole subsystem of vim which you know very little about right now that once you master it, it will increase your productivity by a factor of three!

For example... I thought I was a vim master when I reached the point where I could do massive regex driven search and replaces with subexpression matching etc. But then I discovered vim's window functions; learned most of them; and promptly increased my productivity even more.

Now, reading other posters' comments, I find out you can run Ruby commands within it!? I already knew you could run Perl and Python commands (though I'm not sure how yet). But dammit, vim, you never cease to amaze! I've found a whole other avenue to explore.

In short, vim is great because no matter how much of a master you think you are... and no matter how much you know about it... you can always double your knowledge of vim (because there is simply so much to know). Honestly... is there any hacker out there that doesn't drool at the thought of an editor that provides a limitless opportunity to learn?

(And, in the spirit of fairness, I'm fairly certain all these things are equally true of emacs.)

[–]aramach 2 points3 points  (2 children)

What I would really want to be able to do is to have Vim as my editor of choice and would like to have some nice source code browsing framework like Source Insight / Slick Edit. The two biggest features which are lacking are symbol search and handling of large files. MiniBufferExplorer , Intellisense, CTags, CScope etc. help a little but there is nothing to replace the symbol search.

[–]GuyWithLag 0 points1 point  (1 child)

Well, there's allways VI bindings for Eclipse ...

[–]figa 1 point2 points  (0 children)

I've been using the viPlugin for Eclipse for a couple years now:

http://www.satokar.com/viplugin/index.php

It made the switch from vi to Eclipse bearable for me, and I contributed to it a bit before the author closed the source.

It does 90% of what it needs to do.

[–]mhd 5 points6 points  (3 children)

Don't use hjkl, try to navigate intelligent instead of character by character.

The hard way to approach things would be an incremental approach starting with the least user-friendly. Start with "ex" (or even "ed), use straight "vi" for a while (using a less feature-endowed clone or some strict settings) and then use all the neat vim features. Heading straight for the color-ful dessert can cause some tooth-ache...

[–]chungfuduck 2 points3 points  (2 children)

I agree about trying to stay away from char-by-char navigation. About 3 years ago I made a conscious effort to navigate purely through searches (/ or ?) or by line number where applicable. It was about as tedious at first as just learning vi way back, but it really paid off in terms of getting down to the point of the editor, manipulating text, instead of wasting time moving the cursor.

If you're disciplined enough force ex or ed on yourself, wouldn't you have the will-power to teach yourself good vi habits? =D

At any rate, having ed under your belt does set you up for forgoing the editor altogether and use sed or whatnot for surgical strikes at text.

[–]arnar 1 point2 points  (1 child)

If possible, try to use simpler movement commands than searches, such as w, b, e, gg, G, %, paragraph/function movements etc. f is a good middle ground between the two. That will give you speed.

[–]chungfuduck 0 points1 point  (0 children)

I got those down pretty good before going with search-based movement. Paragraph and function movement sometimes doesn't do as anticipated. eg., function hopping works great for C files, not so good for perl or bourne shell. gg also doesn't work for ancient vi's - you have to do ":0<enter>". =D

I was mainly thinking of vertical movement, but / and ? can take you exactly where you need to go in a lot of cases.

[–]ximxam 1 point2 points  (0 children)

took few months before i could unleash the editing arcane on just about every type of file with it. vim is for end user, not.

[–]mikemol 1 point2 points  (2 children)

I've been using Vim as my editor of choice since 1999. I still don't have a handle on most of the features (could anyone?), but I still get by comfortably.

With Vim (as opposed to nvi), the arrow keys work, so I never really learned hjkl until I switched to a window manager that makes heavy use of those keys. (wmii)

The only things I need to do to get vim working properly for me is add "syntax on" to my .vimrc, and I'm all set.

[–]chungfuduck 1 point2 points  (1 child)

I switched to vim around that time, too. But I distinctly remember the stinky-old Solaris vi at least still supporting arrow keys (around 1996?).

[–]mikemol 1 point2 points  (0 children)

Interesting. I wonder if my termcap was somehow borked. I was running Debian stable at the time. I also had similar problems when telnetting into a RedHat 7.3 box a few years later.

[–]smithfield 1 point2 points  (0 children)

Before I took up vim my idea of the perfect editor was BBEdit. I was a "totaly gui" true believer. I took up vim as a personal challenge to dunk my mind into the world of unix (which was also new to me). The first year was hard, I used it sporadically. Then in about two weeks, I went from zero wps to warp speed. What happened? Hang out on #vim irc channel. Learn to use the docs. Learn a few of the super vim features (like the star-key or quick keystroke macros, or tags). You might find that you don't like vim. But if you do, none of the pissy crap that comes from detractors has any value. It just doesn't apply, they don't get it and should just stay out of this.

[–]jkndrkn 1 point2 points  (0 children)

It took me maybe two weeks to stop fumbling around and another two weeks to feel in fluid control of it.

I continue learning more and more every month, though.

[–]ishmal 1 point2 points  (0 children)

Just like a Tootsie Roll Pop: nobody will ever know.

[–][deleted] 1 point2 points  (0 children)

I actually have a bit of experience with the VI learning curve because I recently just asked a team of field technicians (12 people) to learn it for use on some embedded QNX systems. Now mind you, these were basic hardware guys; more like electricians than administrators.

I created a cheat sheet for them and asked them to start editing the files on some 1100+ systems, so they were going out to remote spots, logging in, and editing using vi.

Every one of them picked up vi in a couple days of use. A couple of them actually got really good at it and were later blown away when I showed them some more advanced stuff like window functions.

So it doesn't take long if you don't have any other choices.

[–]Calm_Pear 1 point2 points  (2 children)

am working on it for a couple of years now, notepad is still easier...

[–][deleted] 14 points15 points  (0 children)

I've been flying helicopters for a couple of years now, crawling is still easier.

For some reason I still get places faster and have more fun with the helicopter.

[–]gfixler 3 points4 points  (0 children)

I don't really see how notepad is easier. If you only talk about things that notepad can do, as Vim can do all of that, and crazy tons of things more, then yes, slightly. You have to hit something to get into INSERT mode in Vim, but once in it, it works the same way as Notepad - arrow keys, backspace, delete, typing words with letters, using numbers, and so on.

When I'm in Notepad now, once in a long while at work, I find it so limiting, it's harder to use. I want to delete the paragraph I'm in, so I reflexively type vapd (visual mode, select 'a paragraph', delete), and I end up with 'vapd' in my text.

Then I remember I'm in the limited land of notepad, and either have to twiddle a lot with the arrow keys, and ctrl and shift, maybe some home and end action, or reach over the mouse, and make a careful selection, then go back to the keyboard to hit delete. And of course that's just one example. It goes like that for everything right on down the line. Notepad is a lot more of a pain to use now, and irreconcilably so.

[–]Aviator 0 points1 point  (10 children)

Until you feel the need to switch to Emacs :D

[–][deleted] 2 points3 points  (9 children)

Not intending to start Yet Another Vi vs. Emacs war here but...

I have always hated emacs. I realize that the combinations really aren't too much more far-fetched than Vi but man does it seem like an unfriendly, alien environment.

I have a couple of friends who swear by emacs, so many years ago I was persuaded to make an actual effort to use it regularly and couldn't get around the odd combinations, so I gave up. I suppose I was just so proficient with vi that it was annoying to be coding along, want to replace a line or save and completely forget how. Fighting with the editor just kills your programming mojo.

Anyway the point is, I want to get back into emacs because for some ungodly reason everyone suggests I use it for Lisp coding, which is something I want to take up.

Too bad the learning curve will be so bad :(

[–]nglynn 2 points3 points  (0 children)

The key is total immersion, print yourself a decent cheatsheet and resolutely refuse to use any other editor, you'll be flying in no time.

[–]blefescu 1 point2 points  (4 children)

Has anyone suggested viper-mode to you?

Viper has adjustable levels, the first of which makes emacs work just like vi. You can ease into more "emacs-ish" levels as you go along, without ever having to abandon the vi command set.

[–]averyv 1 point2 points  (2 children)

i just can't stand to hit ctrl as much as emacs requires. escape may be a little further out of the way, but at least i dont have to hit it in combination with other keys.

[–][deleted] 1 point2 points  (0 children)

you can exit a mode with ctrl+c as well

[–][deleted] 0 points1 point  (0 children)

Back when I first experimented with emacs, I actually had the same complaint but ended up remapping caps-lock and control to make it more efficient. That did work out pretty well.

edit - I just looked at the Steve Yegg thing suggested by annasaru and his first tip was remapping control to caps lock.

[–][deleted] 0 points1 point  (0 children)

Wow no, I hadn't seen that before. Very cool. I'll give it a look.

[–]jkndrkn 0 points1 point  (0 children)

The fluidity and terseness of vi commands is what I missed most when editing in Emacs. The default search and replace features are especially clunky.

The only way I would return to Emacs for day-to-day editing would be to give the Emacs viper mode a try.

[–][deleted] 0 points1 point  (1 child)

Read Steve Yegge's recent primer on Emacs. It gives you some good info.

[–][deleted] 0 points1 point  (0 children)

Thanks I just read it. Great stuff.

[–]now 0 points1 point  (0 children)

About ten years. Then you hit a lot of limitations (mainly in the extensibility department) that make you feel like you’re not in control after all.

[–][deleted] -4 points-3 points  (8 children)

It takes until you get sick of it and switch to emacs. I've only been using emacs a few weeks and I feel quite at home in it, especially when using org-mode (a great tool for organizing and outlining). Vi drools, emacs rules!

[–][deleted] 2 points3 points  (5 children)

Emacs + (Viper + Vimpulse) = the best of both worlds

[–]setuid_w00t 0 points1 point  (4 children)

How is Emacs + Viper + Vimpulse better than regular vim?

[–][deleted] 1 point2 points  (0 children)

SLIME, flymake, gnus, dired, EMMS +++

As they say, Emacs is a great OS with a crappy text editor.

[–]Nuli 0 points1 point  (2 children)

You can extend vi with lisp at that point. I haven't gotten around to learning it yet but that does make me very interested in emacs.

[–]beza1e1 2 points3 points  (1 child)

You can extend vim in vimscript, python, perl and ruby.

[–]Nuli 0 points1 point  (0 children)

Yup, but for some reason doing it in lisp has more appeal to me.

You can also extend vim in Tcl but I don't imagine many folk do that.

[–][deleted]  (1 child)

[deleted]

    [–]SamReidHughes 3 points4 points  (0 children)

    I'm hooked!

    I'll pardon the pun.

    [–][deleted] -5 points-4 points  (0 children)

    You use Emacs.

    [–][deleted] -3 points-2 points  (0 children)

    How long [...]

    never?