News for hackers. Stuff that matters.
Re:Vim, you complete me by cletus on Thursday July 12, 2012 @02:33PM (#4235927)
Vim reminds me of an example from Bret Victor's excellent talk Inventing on Principle [1] (which you should watch from beginning to end if you've somehow been hiding under a rock and have missed it).

Bret mentions Larry Tesla (starting at about 38:10) who made it his personal mission to eliminate modes from software.

This is the problem I've always had with Vim and I suspect I'm not alone in this. I find the concepts of modes jarring, even antiquated. Everyone who has used vi(m) has copied and pasted text in while in command mode and done who knows what.

Emacs is better in this regard but I find Emacs's need to consecutive key presses (or a key press followed by a command) to be longwinded.

The advantage of either is they're easy to use over ssh+screen (or tmux) for resuming sessions.

That all being said, give me a functional IDE any day. IDEs understand the language syntax. Vim can do a reasonable job of this. Emacs (with elisp) seems to do a better job (or so it appears; I'm no expert) but IDEs (my personal favourite being IntelliJ) just make everything easier. Things as simple as left-clicking on a method and going to its definition.

For statically typed languages (eg Java/C#), IDEs (quite rightly) rule supreme. Static code analysis, auto-completion, etc are just so much better than text-based editors.

Dynamic languages are more of a mixed bag and its certainly the norm for, say, Python and Ruby programmers to use one of these.

Still, give me an IDE any day.

One objection seems to be that people don't like using the mouse. I tend to think the speed differences over not using the mouse are largely illusory.

Anyway, I can use vim but I've never felt comfortable in it and I don't think I ever will and modes are the primary reason.

EDIT: I realize there are plugins and workarounds for many of these things but that's kinda the point: I don't want to spend hours/days/weeks/years messing with my config to get it "just right".

Also, instead of archaic commands to, say, find matching opening/closing braces (which tend to involve an imperfect understanding of the language), IntelliJ just highlights matching braces/parentheses, where a variable is used and so on.

[1[: http://www.youtube.com/watch?v=PUv66718DII

Re:Vim, you complete me by jes5199 on Thursday July 12, 2012 @02:43PM (#4236004)
The way that most Vim users use modes is like using "StickyKeys" on your Shift/Control/Option keys. You smack "i" or "a" to go into insert mode just for the duration that you need it, and then you smack Escape the moment that you stop typing, even if it's just pausing to think.

Also, if you use a GUI version of Vim, then it knows about "paste" and doesn't make the mistake of interpreting your paste buffer as keystrokes.

Re:Vim, you complete me by dave1010uk on Thursday July 12, 2012 @05:30PM (#4236957)
I think this is the key to vim. It's a revelation or a turning point in how you use it. You change to insert mode to insert text; you don't change to normal mode (to do text operations) as you're already in normal model.
Re:Vim, you complete me by aerique on Thursday July 12, 2012 @04:35PM (#4236636)
Emacs is better in this regard but I find Emacs's need to consecutive key presses (or a key press followed by a command) to be longwinded.

These consecutive key presses ("chords") are just there to provide default bindings and are one of Emacs' weakest points since they're universally horrid. However, there's no single best way to use Emacs[1]: everyone should configure it how they want it to. After years of using my own key bindings I've streamlined them with the rest of my OS[2] and couldn't be happier.

[1] Opposite IMHO to Vi(m) where one should use the default key bindings.

[2] CTRL/CMD-o to open a file, C-s to save, C-f for incremental search, etc.

Re:Vim, you complete me by martininmelb on Thursday July 12, 2012 @05:57PM (#4237082)
I used to use IntelliJ when I programmed in Java and loved it. I was still learning Java and its ability to show help, check syntax and refactor was excellent. But then I did less Java and more Python and returned to vim. One issue was that I was not only editing code, I was writing documents in LaTex, I was editing large 'data' files (ascii text), I was editing blogs and other notes in Markdown etc. Unfortunately, IntelliJ seems to regard everything as a project and does not make it easy (at least back then) to simply create or edit a file that is not part of a particular project.

Another advantage of vim is that most of the time at work I am working on a PC but editing files on Linux boxes. At home I am on a mac. I know I could run X, but I prefer running Putty, and I enjoy the lightweight nature of just bringing up vim. So, currently, vim is my editor of choice.

Also, I must admit that after 20+ years of using vi/vim, I still make the occasional mode mistake and type 'i' when in insert mode, or ':wq', but vim is still my favourite editor.

Re:Vim, you complete me by Ralith on Thursday July 12, 2012 @03:07PM (#4236123)
Given that emacs (and I expect vim) can do all of that and then some, for languages both static and dynamic while taking a fraction of the resources of a monolithic IDE and permitting to use the same editor across all your projects, it seems that your only actual problem is that the default configs are not to your taste.
Re:Vim, you complete me by cageface on Thursday July 12, 2012 @03:16PM (#4236198)
My laptop can run a full-featured IDE (IntelliJ) without breaking a sweat and it supports all the languages I need and then some.

I guess I could go back to trying to hack together an IDE in emacs or vim with a bunch of buggy, half-supported third party plugins that interoperate poorly if at all, but why?

Re:Vim, you complete me by Ralith on Thursday July 12, 2012 @03:45PM (#4236359)
> My laptop can run a full-featured IDE (IntelliJ) without breaking a sweat and it supports all the languages I need and then some.

I've had a quad-core desktop chug under Eclipse (employer required I use it) and still had to fall back to a real editor regularly.

> I guess I could go back to trying to hack together an IDE in emacs or vim with a bunch of buggy, half-supported third party plugins that interoperate poorly if at all, but why?

Well, mostly people use the well-maintained, integrated, and first-party ones instead. Each to his own, I suppose!

Re:Vim, you complete me by modarts on Thursday July 12, 2012 @11:20PM (#4238065)
"real editor"? As opposed to what?
Re:Vim, you complete me by Ralith on Friday July 13, 2012 @02:03PM (#4240971)
As opposed to IDEs, which are characterized by having tightly constrained domains and weak editing features beyond whatever language-specific functionality they bloat up their GUIs with.
Re:Vim, you complete me by modarts on Saturday July 14, 2012 @04:29AM (#4243579)
An editing environment that makes it easy to develop in a specific domain doesn't make it any less "real" than any other environment.
Re:Vim, you complete me by irahul on Thursday July 12, 2012 @03:00PM (#4236078)
> Everyone who has used vi(m) has copied and pasted text in while in command mode and done who knows what.

If you are using vim, you should play per vim rules. When you are entering text, you enter insert mode. When you are done, back to command mode. Once you have that mental model, you don't try to c-v(or c-shift-v or whatever) in command mode. Also, if you are willing to try vim, grab a vim build with clipboard support and copy-paste from within vim(=+p paste clipboard, =p paste x selection, =+y{motion} copy to clipboard ... in command mode; or ctrl-r+ paste from clipboard, ctrl-r paste from x selection in insert mode)

> I find the concepts of modes jarring, even antiquated.

The thing I like about vim is translating intent to vim commands - delete 10 lines and then move to the top of the file 10ddG, delete everything inside these parens and put me in insert mode cib etc. Without modes, these won't be as short and sweet. You will be left with long key combinations - the way emacs does it.

> Emacs is better in this regard but I find Emacs's need to consecutive key presses (or a key press followed by a command) to be longwinded.

Isn't that obvious? If you always want to be in insert mode, how else will the special instructions be entered?

> The advantage of either is they're easy to use over ssh+screen (or tmux) for resuming sessions.

And they are very good at editing text, and majority of programming languages, though might require some configuration.

> For statically typed languages (eg Java/C#), IDEs (quite rightly) rule supreme. Static code analysis, auto-completion, etc are just so much better than text-based editors.

I generally am able to find something for Vim which makes language specific stuff easy.

Clojure - http://www.vim.org/scripts/script.php?script_id=2501 Java - http://eclim.org/ Go - https://github.com/nsf/gocode C - http://www.vim.org/scripts/script.php?script_id=3302 Python - http://rope.sourceforge.net/ropevim.html

And a lot more...

> I tend to think the speed differences over not using the mouse are largely illusory.

Doesn't that depend on the task? What will be faster - ctrl-f on this page or clicking edit(or some menu)->find?

Also, for me, it is more about having my fingers on home row is the sweet spot and moving my fingers from my sweet spot is irritating.

Re:Vim, you complete me by flyinRyan on Friday July 13, 2012 @08:41AM (#4239546)
>If you are using vim, you should play per vim rules.

This issue is that studies show us vim's rules are wrong: modal editing is a source of confusion and error. I used vi[m] exclusively for 8 years or so and until the very last day I could still make major modal based errors.

Re:Vim, you complete me by irahul on Friday July 13, 2012 @09:30AM (#4239699)
> This issue is that studies show us vim's rules are wrong: modal editing is a source of confusion and error.

The so called studies show people who aren't used to modes are confused when using a modal editor.

> I used vi[m] exclusively for 8 years or so and until the very last day I could still make major modal based errors.

I have been using vim exclusively for 5 years now. And I stopped making modal based errors after 2 weeks. My anecdote cancels yours?

From what I have seen, people who leave vim in insert mode are the ones making mode errors. Insert mode isn't the rest mode for vim, normal mode is. You are bound to make errors when starting because out of habit, your mind assumes insert mode as the rest state.

Re:Vim, you complete me by flyinRyan on Friday July 13, 2012 @10:13AM (#4239868)
>The so called studies show people who aren't used to modes are confused when using a modal editor.

"Don't listen to this study, listen to my firmly held belief". That's not how this works. If you want to combat a study you need to do so with another one, not by just saying throwing out untested assumptions.

>From what I have seen, people who leave vim in insert mode are the ones making mode errors. Insert mode isn't the rest mode for vim, normal mode is. You are bound to make errors when starting because out of habit, your mind assumes insert mode as the rest state.

Thanks for the condescension. Have you ever started to type a word and had your hands just finish it for you? Sometimes there will be some relatively large word that I type out commonly enough that when my hands notice the first few letters of it they'll type it out automatically with me having to go back and delete it and type out the similar starting word I meant to write. I even recall having my hands do it again on the correction once.

Having this kind of muscle memory is a killer for vi usage. Lots of times I have intentionally left the editor in insert mode for just a second while I grab some text from, say, a website to paste in. What I didn't realize is that my hands knew to always get back to command mode when changing screens so even though my mind had tried to save keystrokes my hands defeated me. The result? Pasted a huge document into command mode. Great. Similar sync issues came up regularly enough that I typically mashed Esc 2-4 times (in case there was, e.g. a command active that would write in the Esc char) rapidly before starting anything to ensure that I was where I thought I was.

In my experience, I wouldn't get the time savings I should have been getting due to having to slow down for the mode management.

Re:Vim, you complete me by irahul on Friday July 13, 2012 @04:00PM (#4241585)
> "Don't listen to this study, listen to my firmly held belief". That's not how this works. If you want to combat a study you need to do so with another one, not by just saying throwing out untested assumptions.

Yeah. Combat the studies that you totally provided the link to. Throwing claims around saying "scientists say that" or "studies have proved that" is surely not how it works.

> Thanks for the condescension.

What part was condescending? Leaving vim in insert mode causes errors? The rest state of vim is normal mode?

> Having this kind of muscle memory is a killer for vi usage for you

You are extrapolating personal anecdotes to absolutes.

Re:Vim, you complete me by raphaelb on Friday July 13, 2012 @12:54PM (#4240597)
To be fair you didn't link these studies you speak of either. Modes never seemed to bother me very much and I've been using vim for a while but I can understand the difficulties with it.

Also it occurs to me that I may do some of those things like mashing esc repeatedly just to be sure subconsciously.

Re:Vim, you complete me by tincholio on Sunday July 15, 2012 @11:15AM (#4247086)
> If you want to combat a study you need to do so with another one, not by just saying throwing out untested assumptions.

You can just show that the methodology is flawed, no need to repeat the experiments in all cases

Re:Vim, you complete me by antidoh on Saturday July 14, 2012 @12:05PM (#4244518)
"This issue is that studies show us vim's rules are wrong:"

If using vim is wrong, I don't want to be right.

Honestly, I can believe such studies, and I still would use vim.

One, my shoulder gets tired and sometimes hurts if I move back and forth between keyboard and mouse too much.

Two, by the time I move to the mouse and back, I could have done the equivalent twice on the keyboard and moved on.

Three, there is nothing sweeter than "How did you do that?" :)

Re:Vim, you complete me by flyinRyan on Monday July 16, 2012 @05:53AM (#4249989)
>One, my shoulder gets tired and sometimes hurts if I move back and forth between keyboard and mouse too much.

>Two, by the time I move to the mouse and back, I could have done the equivalent twice on the keyboard and moved on.

Vim got this part right, and it ends up being better than Emacs in that regard: in Emacs you also don't need the mouse but all the chording requires moving the hands too much. Ideal would be to take Emacs' non-modal editing and combine it with Vi's simply edit mode: for example, say you are in "command mode" only if you hold down Caps lock, but when the button isn't held down the editor is always in insert mode.

Re:Vim, you complete me by ibotty on Friday July 13, 2012 @09:12AM (#4239641)
> Everyone who has used vi(m) has copied and pasted text in while in command mode and done who knows what.

try to set mousemode (vim) if vim is compiled with x11-support.