News for hackers. Stuff that matters.
Re:Two Simple Steps Helped Me Learn Vim by MrBuddyCasino on Wednesday December 10, 2014 @09:25AM (#8729258)
Time and again, these "how to coerce yourself into learning this hostile tool called vim" posts appear. I read them, and it sparks my interest.

But usually, whats missing is part 2, which goes: "... and this is why it was so totally worth it". An no, just because it works over SSH and is installed on every server is not quite sufficient.

Also, are you programming in a script language or a .NET or JVM behemoth?

Re:Two Simple Steps Helped Me Learn Vim by DEinspanjer on Wednesday December 10, 2014 @09:42AM (#8729332)
I first saw Vim in use back in 2000. I was working at NuMega (Compuware lab at the time) and I was a Windows only user that was just starting to get very comfortable with the DOS prompt and I used Notepad for any editing that wasn't done in Visual Studio.

I had some huge file in which I had to do a bunch of refactoring. Some search and replace, and some reorganization.

I had been plodding away, copying, pasting, and repetitively hitting the arrow keys and typing a few characters in each place for about 5 minutes when a friend came over and saw what I was doing. He was an absolute *nix expert. After a few moments, he told me that he could finish all those changes in just a minute. I had seen him code in Vim before, and was impressed, but it seemed like magic at the time. I saved the file and went over to his desk and asked him to walk me through exactly what he was going to do. He loaded the file up in Vim and started with a quick regex that knocked out 80% of the work. He then recorded a macro that yanked the current counter number into a buffer, searched for the next edit position, pasted in the counter number, incremented it, then shifted position to the next code block and updated that reference as well. He then asked me about how many sections there were. I said about a hundred, so he typed 99@q and poof! There were a few more, so he did a :g/<some keyword>/p to see how many lines there were and then did that many more macro invocations and the file was done.

I was hooked at that point. He set me up with gVim and some tutorials and taught me the most basic fundamentals and told me that it didn't matter if I couldn't make vimgolf par for the first year or so. If I used it and every once in a while picked up a new motion or command, after a few years, it would change my coding life.

He was right.

Re:Two Simple Steps Helped Me Learn Vim by jpradeek on Wednesday December 10, 2014 @09:51AM (#8729394)
For me, I was always annoyed with how tedious it was to edit things. i.e, The gap between what I think vs what I have to do in the editor to get it done. This constant annoyance was what drove me to spend time and energy into learning it. I believe that if you don't care about it, you won't really benefit out of it. Because the whole point of switching to Vim/Emacs is to minimise the gap between what you think and how you do it.

Let me give you an example. You'll be thinking, "I need to change all the arguments to a function." In other editors, you'll press the arrow keys until you get to one end, press backspace key multiple times until you get to the other end. In Vim, I'd do "ci(" which means "change everything inside (" - which is pretty much how I think about what I need to do. A similar but more common example is changing text inside quotes. Again, that'd be 'ci"'.

Not everyone feels the annoyance about this and if you don'tt, hats totally fine. Learning something just because its cool is never worth it. Learn it if you really care about it.

Also read this post by Yehuda Katz about how he started for some ideas. http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convi...

Re:Two Simple Steps Helped Me Learn Vim by Someone1234 on Wednesday December 10, 2014 @10:01AM (#8729465)
Your example falls flat. Any text editor with regular expression support can do that...

Do you have another example?

Re:Two Simple Steps Helped Me Learn Vim by adolph on Wednesday December 10, 2014 @01:53PM (#8730901)
I think you are missing the elegance. The example isn't change foo to bar in f1(foo); f2(foo); f3(foo). The example is the series of steps and physical mode changes to change f(foo) to f(bar).

To do this one must select the letters foo somehow and then cause bar to be typed in their place. This can be done a number of ways in a "normal" text editor. For example, the person might double-click foo with the mouse to select the word and then type in bar. This does four things: 1. places the cursor in the location of foo; 2. select foo; 3. remove foo; 4. insert bar. In this example, there is one or two physical input context changes: from keyboard to mouse and back or maybe just from mouse to keyboard.

In vim, the physical input context never changes. The keyboard remains your context throughout. The person would 1. Position the cursor somewhere by foo (i.e. by typing a search expression like /foo<enter>); 2. type ci(<enter> which selects everything in the parenthesis, deletes and changes the context to input; 3. type bar (and probably 4. press the <esc> key).

I suspect that some people aren't bugged very much by the physical context switch and so the point of this is lost. Other people are bugged by it and struggle along until they find vi, emacs or the like.

Re:Two Simple Steps Helped Me Learn Vim by inclemnet on Wednesday December 10, 2014 @10:32AM (#8729643)
Pepole don't use vim because it does things that are simply impossible in other editors - they use it because they find it lets them do that thing better. In this case, I guess the main point is about vim's modal editing in which the command is simple, easy to type and obeys a meaningful grammar.
Re:Two Simple Steps Helped Me Learn Vim by Hello71 on Wednesday December 10, 2014 @10:30AM (#8729629)
vim:

step 1: type ci(. step 2: type what you want to replace with. step 3: press ESC.

notepad++:

step 1: press Ctrl-H. step 2: type \([^)]*\). step 3: press tab. step 4: press (. step 5: type what you want to replace with. step 6: press ). step 7: move hand to mouse. step 8: move cursor to and click on "Regular expression". step 9: press enter.

Do you have another example?

Re:Two Simple Steps Helped Me Learn Vim by therealunreal on Wednesday December 10, 2014 @10:41AM (#8729704)
Not implying that the vim way isn't faster but on any regular text editor you can:

ctrl+right arrow once or twice, right arrow to skip the (, shift+end, shift+left arrow, then type.

Re:Two Simple Steps Helped Me Learn Vim by dllthomas on Wednesday December 10, 2014 @11:03AM (#8729837)
And of course, \([^)]*\) breaks if you have foo(bar(), x / (y + 1))
Re:Two Simple Steps Helped Me Learn Vim by hderms on Wednesday December 10, 2014 @10:47AM (#8729753)
The reason why it's interesting is it is basically a grammer for editing text. It's simple enough that you can easily create new strings of grammar which do what you want but powerful enough that the skill ceiling is practically infinite. Once you have a grammar for editing text a lot of interesting features fall into place quite naturally like having 'undo trees' instead of just linear undo, being able to write complex macros in the same language you edit text in, etc...
Re:Two Simple Steps Helped Me Learn Vim by kovrik on Wednesday December 10, 2014 @09:42AM (#8729337)
I think that it is necessary to learn Vim not because it is the best text editor (it's not!), but because it is one of the best ways to edit texts.

It was hard for me to get used to it (I forced myself to write all scripts - Perl, Bash etc. - in Vim). But it was absolutely worth it. Now I use vim mode in browser, in huge Java IDE (Idea), in file manager etc.

Vim (as an editor) has many disadvantages (Google it). But it is a superior way to edit texts. I switched to Emacs recently (for LISP-coding), but immediately downloaded Evil package. Now I have best from both worlds :)

Yes, I use Emacs, but my love is Vim.

My point is: all text editors are just tools. But try to learn Vim way to edit texts.

Re:Two Simple Steps Helped Me Learn Vim by MrBuddyCasino on Wednesday December 10, 2014 @10:59AM (#8729819)
Interesting - so IDE + Vim mode would be the best of both worlds. Do you find there is a lot lost in translation, or does that feeling carry over well? I'd be especially interested in Emacs and IDEA.
Re:Two Simple Steps Helped Me Learn Vim by dllthomas on Wednesday December 10, 2014 @11:05AM (#8729850)
I've typically found that vim impersonations miss at least a couple features that I use regularly. I've heard that Evil, in particular, is pretty complete though.
Re:Two Simple Steps Helped Me Learn Vim by sea6ear on Wednesday December 10, 2014 @12:20PM (#8730318)
Evil is the first Vi/Vim emulation package that didn't frustrate me pretty intensely with things that didn't quite work as expected coming from Vim.

However, it doesn't attempt to turn Emacs into Vim, it's more like it gives Emacs an acceptable Vi interface for the places where that matters.

As a result, if you are using both Vim and Emacs contemporaneously, it's still easy to develop habits in one, that will cause you pain in the other.

For example, because Evil still allows you to do a lot of Emacs shortcuts, and because :q kills Emacs if there's only one window open, I find myself doing C-x k a lot to git rid of buffers.

However, that causes huge pain when I accidentally do that when I'm back in Vim. Instead I should really get in the habit of using :bd to get rid of buffers, but that's one aspect of Vim that I've never fully moved to from using naive vi style :q.

Re:Two Simple Steps Helped Me Learn Vim by sophacles on Wednesday December 10, 2014 @09:49AM (#8729375)
I think a great answer to this question is in this stack overflow answer: http://stackoverflow.com/questions/1218390/what-is-your-most...

To answer you second question: yes. I've done quick scripts and giant programs in vim. Also note: I use full IDEs in conjunction with vim where appropriate - I mean, why wouldn't I take advantage of Visual Studio when doing C#, but even then I still regularly drop into Vim (because of the stuff in the above link).

Re:Two Simple Steps Helped Me Learn Vim by Kurtz79 on Wednesday December 10, 2014 @09:42AM (#8729331)
"... and this is why it was so totally worth it".

This is something that is difficult to explain, but absolutely clear to you once you have achieved some degree of efficiency.

Muscle memory makes the editor disappear and let you focus, not on the keyboard, not on the menus, but on code itself.

I suggest you watch some live-coding videos of people very experienced in the editor to get an idea (in this case the programmer uses emacs, but the concept is the same):

https://www.youtube.com/user/handmadeheroarchive

Re:Two Simple Steps Helped Me Learn Vim by rballonline on Wednesday December 10, 2014 @07:52PM (#8732630)
Do you know what is the guy using within VS here? Is this an Emacs extension or something added on top. He seems to be going full screen and switching files very quickly. I've seen this before on someone's machine but didn't ask about it. I don't know anything about emacs myself.
Re:Two Simple Steps Helped Me Learn Vim by Kurtz79 on Friday December 12, 2014 @02:48PM (#8742290)
I'm a vim guy, but the strength of emacs is that is basically running on its own lisp, so it's completely programmable.

He's likely to be running a customized version.

Re:Two Simple Steps Helped Me Learn Vim by hereonbusiness on Wednesday December 10, 2014 @08:21PM (#8732697)
I had/have to use vim almost every day (a lot of it was managing headless servers, but also being a linux user myself), and it was somewhat of a pita every time I used it, but a bit less so than nano, pico or what have you. After some time I finally had enough and decided to invest some time in figuring it out mostly in the hope of making it a bit less of a pita. Also, so many people seemed to just love using vim. Makes you think that it may not be the most pointless thing in the world to invest some time in.

What I got from it personally is:

Most text editors now feel like there's not much to them, you rote learn the editor specific shortcuts, but they often don't have any meaning on their own so there is a tendency to forget them when they aren't used every day. Luckily the ones used most are often somewhat consistent across editors so it doesn't take much time to get to some level of proficiency with a new editor. Also you often have to use your mouse and sometimes arrow keys for efficient movement and text selection. This requires constantly moving one of your hands out of the typing position which seems a lot more distracting if you get somewhat used to "mouseless" text editing.

With vi(m), yes, you have to learn the shortcuts/commands but they kind of add together, almost every command or way to do something seems not only useful by itself but also expands your vocabulary and enables you to tell the editor what it should do in a more efficient way. In a way you are making up shortcuts on the fly all the time by composing commands you know depending on what you want to do, only most of the time (at least while editing text) you don't actually think about commands or shortcuts just like you don't have to think about ctrl+x and ctrl+v, it's just select, cut, paste.

tl;dr, my opinion

Is it worth spending the time and effort given the steep learning curve? If you don't already use vim at least some of the time and would have to force yourself into using it, I personally would say no. I think I still would have tried it but I don't know if I would have stuck with it once the novelty had worn off. I wasn't really unhappy with text editors, I just didn't like using vim the way I was using it. Also you end up adding "vim mode" plugins to every damn thing you type text into, IDE's (used for those behemoths), other text editors, web browsers, ...

Re:Two Simple Steps Helped Me Learn Vim by marktangotango on Wednesday December 10, 2014 @10:18AM (#8729562)
The ssh/server thing you noted is what got me; being able to search and navigate in really large log files on the cluster I used to work on. That was my gateway drug. I don't use it full time, but I use it quiet a bit now.
Re:Two Simple Steps Helped Me Learn Vim by DigitalJack on Wednesday December 10, 2014 @10:34AM (#8729655)
It's worth it for the same reason dvorak is worth it (to those who master it.)
Re:Two Simple Steps Helped Me Learn Vim by MrBuddyCasino on Wednesday December 10, 2014 @12:12PM (#8730265)
Mandatory XKCD: http://xkcd.com/561/