You are not logged in.
Hello All,
I went through college recently, got my CS major and have only used MS products and compilers and IDE's the whole time! That's what happens when you live in WA, I suppose.
I had a few run-ins with linux in my college days but it didn't stick. Recently I discovered arch and it stuck. The keep it simple attitude combined with awesome package management that you don't have wait for (gentoo compile times yikes). In short I'm really enjoying it.
Anyway, I'm here now and I'm just starting to edit code with Vim and I just discovered Gvim. I've been just leaving a terminal open and switching to it to compile/run the code and editing in the Gvim window. This works, but it's...just not that slick.
What I'm here to ask is how YOU do it? Mostly I'm asking Vim users, but if you've got a slick system for editing/compiling code I'd love to hear about it.
I've got eclipse downloaded and installed with cdt, it works like a champ but I've been really enjoying Vim, and I want to continue to use it and get faster with it.
I've seen screen shots of code completion inside Vim as well. That would be slick.
Basically, can I get code completion and compiling done inside the Vim window? How about breakpoints for debugging?
How about 2 of 3?
Thanks for the help and thanks to the arch devs!
Offline
Well, see :help make for starters.
Offline
So a make file is required to build within Vim?
Offline
I believe you can use any program, as long as you tell Vim the proper command to run. A makefile or equivalent is probably easiest in the long run.
Breakpoints seem to be controlled with :breakadd and :breakdel.
I don't actually program with Vim myself. I use Emacs+Slime, since it's pretty much the best Lisp development environment around. This is just some hints that I've picked up.
Offline
It's actually a lot easier. with :! program you can run any program from vi. For example to compile and run in java:
:w
:! javac % (vim substitutes the % with the file you are editing)
:! java package.MainClass
Since vim keeps history of commands you only have to type it once, then you can use the up arrow
Tabs are also very useful when editing source code:
:tabe file (to open file in a new tab)
gt (to move between tabs)
Offline
There are many vim plugins available some of which give vim IDE-like features:
http://www.vim.org/scripts/script_search_results.php
The main ones I use are:
taglist: navigating within a file (and also between)
bufexplorer: navigating between files
NERD_commenter
They have code completion plugins there for various languages.
And, here's a debugger plugin:
"I know nothing except the fact of my ignorance."
- Socrates
Offline
Anyway, I'm here now and I'm just starting to edit code with Vim and I just discovered Gvim. I've been just leaving a terminal open and switching to it to compile/run the code and editing in the Gvim window. This works, but it's...just not that slick.
Well, the way it *should* work, is actually not the :!command way others have shown here, though that is very useful.
Vim comes bundled with (and there's tons more on www.vim.org) what are called "compiler" scripts. See /usr/share/vim/compiler.
Let's say we're writing sooooomme.... hmmm.. java code. When we want to compile it, it's as simple as:
:w
:compiler javac
:make
The ":compiler" line only needs to be called once for the lifetime of that session. It actually does two things. It sets 'makeprg', which is the application used when you type ":make". It also sets 'errorformat', which is used to properly parse and find the errors. For instance, it you ran the above and there were 10 errors from javac, vim would, firstly, move to the line of the first error listed, and secondly, fill in a list of errors (not displayed by default) for you to jump around to, and look at. You can use :copen or :cwindow to view the error list after a :make.
Offline
Just two clarifications:
taglist: navigating within a file (and also between)
taglist actually does no navigation. The navigation is built into vim's interface with 'ctags'. It just so happens that taglist _uses_ ctags, and in doing so, it creates tags files for vim to use for navigation.
They have code completion plugins there for various languages.
Code completion itself is facilitated by vim itself. But parsing different languages requires plugins (much like syntax files and everything else). They use functionality called "omni completion". Quite a few of these languages are provided for in the base vim install itself (c, css, html, xml, javascript, ruby, python, and "syntax" which uses a languages syntax definition form completions - a great fallback).
Offline
Speaking of which, is there a tutorial which describes how to use Vim as a development environment rather than just a text editor?
That would be something worth bookmarking.
Some PKGBUILDs: http://members.lycos.co.uk/sweiss3
Offline
phrakture, you may know this one...I've always wondered if there is a quick way to run a java program from Vim without having to type in the whole <code>myprogramname</code> after you compile it, since <code>%</code> obviously won't work since it would have the <code>.java</code> on the end. Is there an easier way to just have the basename of the file?
Offline
Let's say we're writing sooooomme.... hmmm.. java code. When we want to compile it, it's as simple as:
:w :compiler javac :make
The ":compiler" line only needs to be called once for the lifetime of that session. It actually does two things. It sets 'makeprg', which is the application used when you type ":make". It also sets 'errorformat', which is used to properly parse and find the errors. For instance, it you ran the above and there were 10 errors from javac, vim would, firstly, move to the line of the first error listed, and secondly, fill in a list of errors (not displayed by default) for you to jump around to, and look at. You can use :copen or :cwindow to view the error list after a :make.
I'm trying to use this, and i have to tipe :make %, else javac complains about not getting arguments. :?
Offline
phrakture, you may know this one...I've always wondered if there is a quick way to run a java program from Vim without having to type in the whole <code>myprogramname</code> after you compile it, since <code>%</code> obviously won't work since it would have the <code>.java</code> on the end. Is there an easier way to just have the basename of the file?
Here ya go:
:make %:r.java
For more:
:h expand
Offline
If you need something like Eclipse (I mean some of eclipse features), but more lightweight, like VIM, try eclim [1]. Eclim "brings Eclipse functionality to Vim". It sounds like you need.
See you
NeOnsKuLL
[1] Eclim AUR Page
Intel Core 2 Duo E8400 3.0 GHz | 2x1GB 667MHz | 250+750GB Seageate SATAII | Samsung 19" TFT 1440x900
Openbox + obmenugen + PyTyle | bmpanel2 | oblogout | conky | pyBgSetter (with Esetroot as backend)
Projects: obmenugen, pyBgSetter
Offline
elasticdog wrote:phrakture, you may know this one...I've always wondered if there is a quick way to run a java program from Vim without having to type in the whole <code>myprogramname</code> after you compile it, since <code>%</code> obviously won't work since it would have the <code>.java</code> on the end. Is there an easier way to just have the basename of the file?
Here ya go:
:make %:r.java For more: :h expand
Damn! You never cease to amaze me with Vim knowledge, thanks. Must...learn...more...
Reading the help file and messing around with it a bit yields this set of commands to compile and then run a java program:
:make %
:!java %:r
VERY COOL!
Offline
So I was looking for a way to have a dwm like setup.
Best new key stroke : CTRL-w CTRL-r
rotates windows. Now I can have a fake zoom like dwm. Hurrah!
Offline