41 points · by surfingdino · 15y ago · 67 comments
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!
This sounds very interesting.
I've long wanted vim integration with Opera, so I'm not stuck with its relatively primitive editing features when I'm filling out a text input box. Unfortunately, vim does not integrate with other apps very easily.[1] So something along the lines you're working on would be very welcome, even if it is primitive compared to vim.
One thing I hope it can do is have an easy way to activate and deactivate it, so it doesn't interfere with editing in vim itself.
- 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) on every system I'm going to need to use.
These are, incidentally, the same reasons I use QWERTY instead of Dvorak.
It's been fun, either way. Time will tell if it ends up being practical.
Although it did make using Emacs less painful, it still required way too much knowledge of Emacs to use effectively and configure than I had time to dedicate to learning it.
Emacs+SLIME+vimpulse+viper might be good enough for someone who already knows Emacs or who hasn't invested a lot of time in learning vim. But for someone fluent in vim, I just don't think huge time investment in learning Emacs well is worth it.
I've basically been translating the shortcuts and techniques I use in vim into some ugly elisp, bit by bit, assuming they don't work as expected with vimpule/viper. I wouldn't say it's an amazing solution, but mucking through the emacs docs to get things working has been a quick way to get a basic proficiency in how emacs works, and how elisp can be used.
Ultimately I still end up in vim for most of my editing, and I keep tacking things onto emacs as I go, but mostly when I'm just writing some clojure. I wouldn't say it's efficient at all; it's just interesting enough to kill time with because my life isn't very busy and it seems 'nifty'.
I'm sure many vim users wonder the same thing. They may also wonder how people can develop using tools that are coupled to each other rather than choosing the various development tools as they see fit.
In any event it's not either/or. The times I've needed Netbeans, for example, I use vim for actual code editing and the IDE for assorted handy click-here-to-run things.
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.
:bufdo %s/foo/bar/g | update
Although I wouldn't knock `bash command madness' for this sort of task. :)The Unix shell is pretty much designed for advanced text manipulation across files. E.g., to replace all instances of foo with bar in HTML files, recursively:
$ find . -name '*.html' -exec perl -i -lpe 's/foo/bar/g' {} \;
vim and the shell are not so far apart and complement each other well, so it pays to understand them both.If you need breakpoints, watchpoints, and a GUI to click around in, your code is too complicated and unmaintainable, which is probably why you need a debugger in the first place.
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.
http://morganpyne.com/img/hacks/debugging-php-with-vim-and-x...
There are several articles out there on using vim as a fully-fledged IDE and setting up interactive debugging: http://www.koch.ro/blog/index.php?/archives/63-VIM-an-a-PHP-... http://tech.blog.box.net/2007/06/20/how-to-debug-php-with-vi... http://colonelpanic.net/2010/08/debugging-php-in-vim-using-v...
Note that these are for PHP development, but I'm sure some rummaging would uncover suport for whatever langugages you work in.
On the one hand, when developing for a new platform or language, you spend some extra time tweaking on VIM, rather than being able to use the platform developers Eclipse GUI immediately. On the other hand, I've found that being exposed to the command line tools with all their arguments, you are more able to fix problems and automate tasks.
Nothing beats vim for grunting through a pile of code that needs cleaning up. Just set up your IDE and vim to autoload when it detects changes.
My workflow generally goes Edit in vim -> check IDE for syntax errors -> Run/Debug -> repeat.
Now, many of the problems are because C++ is awful (hard to parse, for indenting / formatting), and C++ compilers are awful (20 page error messages).
In particular, I tried half a dozen packages and none could tame C++ template error messages, while xcode, visual studio and cde in eclipse all mastered this years ago. A shame.
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 << END_HERE_SCRIPT%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.)
I use a mix of Elvis and Vim as I'm training up on vi-likes, and I'm not sure which I prefer yet. Vim has more-intuitive-to-me stuff like character-by character deleting (ie characters are removed when you delete, not when you leave Insert mode), but elvis has things like pressing = twice to reflow paragraphs.
Vim may win in the end as Elvis is hard to google for...