Put this in your file ~/.emacs
.
(If you don't have one already, you'll have to create one.)
(require 'cc-mode) ; automatic mode for C code (require 'compile) ; support for compile command (setq compile-command "sh compile") (global-set-key "\C-c\C-c" 'compile) ; make C-c C-c do compile when ; not otherwise specified (defun bind-compile-key () (local-set-key "\C-c\C-c" 'compile)) (add-hook 'c-mode-hook 'bind-compile-key) ; make C-c C-c do compile ; in C modeTo compile, type
C-c C-c
; to jump to the next error,
type C-x `
.
It looks like you can set the makeprg
variable to
./compile
and then use vim's :make
command.
See
:make
command works,
but Constantin Berzan, who has taken 40, has this advice:
This works best for C. If you have a makefile,:make
will call make and take you to the first error.:cc
re-displays the error in the status bar,:cn
and:cp
go to the next and previous errors. To get all the gory details, try:h quickfix
.These commands are probably good enough, but if you want more, you can have it:
- You can set up a shortcut for
:make
, for example I havemap
as a line in my:w :make ~/.vimrc
for F9 to save and compile in one step. If you don't use makefiles, you can customizemakeprg
, for example:set makeprg=sh compile
.- If commands are unambiguous, they can usually be shortened, e.g.
:make
==:mak
,:cclose
==:ccl
etc.
gedit
seems to involve using the mouse; see
Use the mouse? While you're at it, why not wear a ball and chain?