Live data from Hacker News

Reasons To Give The Vim Text Editor A Chance

makeuseof.com

21–30 of 68 posts

Re: Reasons To Give The Vim Text Editor A Chance

#21
post #12
post #7

Earlier quoted context omitted.

Most people that use vim also don't use graphical debuggers. I use the "print" statement.

The only downside to print statements is forgetting to remove them and having some obnoxious message committed.

This is rarely a problem when using tools like darcs, magit, or git-add --patch.

Re: Reasons To Give The Vim Text Editor A Chance

#22
Just last week I was about to start learning Vim, but after perusing the shortcut list I decided I could do better, so I rolled my own. Basically it's just a multi-modal keystroke catcher/dispatcher running transparently in the background. The upshot is that most of the commands work transparently in my IDE, in notepad, and even this little textbox I'm typing in right now!

Unfortunately, the original point was to increase my productivity, which I've failed at horribly... because I can't stop playing around with the code!

Re: Reasons To Give The Vim Text Editor A Chance

#23
post #5

I love vim, I use it daily, but always for quick text editing. For real coding I need an IDE (netbeans). I never understood how people can code without debugging, profiling, code exploring. I'll probably get voted down, but, what Vim saves me, I wasted it on debugging. So I don't see any advantage using it as my primary editor.

I'm a full-time Vim user.

This was my problem when I started with Vim. But then I learned to love GDB and other command-line development tools. At first it seemed a bit archaic to me, a Visual Studio user at the time, but when I got a hang of it, I stopped missing IDE debugging. Now I'm at the point where I feel crippled trying to develop in an IDE (no split windows, to vim-style macros, inefficient use of screen space, constantly have to switch between mouse and keyboard).

For example, GDB can be scripted, so you can repeat debugging sessions, your entire debugging session is printed, so you can always go back and see the history of changed values. It supports pretty-printing STL containers and you can add your own pretty-printers in python.

There are a lot more to these tools than you can discover by poking and trying things like you would with an IDE, they have a steeper learning curve, but I wouldn't dismiss them immediately as a waste of time.

Re: Reasons To Give The Vim Text Editor A Chance

#24
post #12
post #7

Earlier quoted context omitted.

Most people that use vim also don't use graphical debuggers. I use the "print" statement.

The only downside to print statements is forgetting to remove them and having some obnoxious message committed.

A useful trick we've had at previous workplaces which solves this (and related accidental-debug-code-checkin) problems is to put a precommit hook that denies a checkin with a certain string in the text (we used "DNCI" for Do Not Check In)

So you get in the habit of annotating test tweaks & debug prints with:

printf("DNCI x is %d\n", x);

I use gdb as well, but sometimes dumping data directly is all you really need.

Re: Reasons To Give The Vim Text Editor A Chance

#25

Just last week I was about to start learning Vim, but after perusing the shortcut list I decided I could do better, so I rolled my own. Basically it's just a multi-modal keystroke catcher/dispatcher running transparently in the background. The upshot is that most of the commands work transparently in my IDE, in notepad, and even this little textbox I'm typing in right now! Unfortunately, the original point was to inc…

Open source it and we can all waste time playing with the code!

Re: Reasons To Give The Vim Text Editor A Chance

#26

My reasons for being a vim user a lot more practical than those I see on these "top 10 reasons for trying X": - In the long run, it's faster to learn and use an "efficiency" editor, so I need to learn one of vim, emacs, notepad++, etc. The differences between these are probably negligible for a proficient user. - Of these, only vim will be installed (or vi, which has a big enough overlap that it won't matter to me) o…

I used to use Dvorak at home and QWERTY at work (as to not annoy my co-workers) and switching between them was a non-issue.

Re: Reasons To Give The Vim Text Editor A Chance

#27
post #5

I love vim, I use it daily, but always for quick text editing. For real coding I need an IDE (netbeans). I never understood how people can code without debugging, profiling, code exploring. I'll probably get voted down, but, what Vim saves me, I wasted it on debugging. So I don't see any advantage using it as my primary editor.

I'm a full-time Vim user. This was my problem when I started with Vim. But then I learned to love GDB and other command-line development tools. At first it seemed a bit archaic to me, a Visual Studio user at the time, but when I got a hang of it, I stopped missing IDE debugging. Now I'm at the point where I feel crippled trying to develop in an IDE (no split windows, to vim-style macros, inefficient use of screen spa…

What about project-wide find and replace? I have been looking to switch to vim, but I do this fairly often and don't see anything that compares to what a good ide can do in vim (without bash command madness).

Re: Reasons To Give The Vim Text Editor A Chance

#28
Reason 8: Vim keystrokes can be incorporated into ex scripts, either alone or in "here" scripts. These commands are already useful, they can do stuff like replace strings in lines that are N lines above or below lines holding another string, and they can be leveraged further via scripting.

For example, a search and replace across files under the working directory:

tgt_string=$1

repl_string=$2

for file_name in $(grep -rl "$tgt_str")

   do
ex - $file_name %s/$tgt_string/$repl_string/g

wq

END_HERE_SCRIPT

    done
Yes, the indentation of the "here" script is ugly, white space before line texts can bork execution.

Yes, sed or awk can do very similar things, maybe better. My point is, it's nice to get some of these capabilities just by knowing your editor.

(Ed: Sorry about the formatting, if I don't double-space the script it turns into one large text clump.)

Re: Reasons To Give The Vim Text Editor A Chance

#29

My reasons for being a vim user a lot more practical than those I see on these "top 10 reasons for trying X": - In the long run, it's faster to learn and use an "efficiency" editor, so I need to learn one of vim, emacs, notepad++, etc. The differences between these are probably negligible for a proficient user. - Of these, only vim will be installed (or vi, which has a big enough overlap that it won't matter to me) o…

Dvorak has actually been shown to really be no better than QWERTY - http://reason.com/archives/1996/06/01/typing-errors/3

You're right about that, but Dvorak is much easier on the hands. The average distance travelled by your fingers is greatly reduced. (It looks like Colemak beats both, though: http://colemak.com/Compare.)

Re: Reasons To Give The Vim Text Editor A Chance

#30
post #14

Earlier quoted context omitted.

Spewing print statements all over a piece of code is as bad as any other shotgun debugging technique. The reason breakpoints and watches were invented were to reduce reliance on bad ways of doing things.

What's good about print statements is that they don't require me to do anything more than once. When you run code in a debugger, there is a lot of manual interaction involved. continue, break, see where you are, think about that, poke around, repeat. With print statements, you run your test, analyze the output, and make the changes. It's all automated except for the analysis step, which is all the human should be doi…

I like logging for this, but the concept is basically the same. Being able to switch on debug logging on a running system has saved the day more than once for me.
Post reply on HN