Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reenter Vim after :! bash?

I'm slowing getting to know Vim and Bash shell scripting and am running into this issue:

When I'm running MacVim, I sometimes want to use the command line to compile whatever it is I'm working on (in this case a small Java program). So I type :! bash and compile whatever it is that I need and test it. Then when I want to go back to the program I was editing I type vim MyProgram.java and get all kinds of messyness in my Vim session like [8;1H~ [9:1H~ [10:1H~ ... etc.

What am I doing wrong here? Can I not jump back into Vim once I've started running the shell inside of it?

Are there better ways of compiling and running your current file?

(I'm using MacVim 7.2 and Bash 3.2.48 on OSX 10.6.2.)

like image 871
Thomas Avatar asked Dec 21 '09 04:12

Thomas


1 Answers

Two suggestions:

  1. Use exit to quit the bash shell and return to vim.
  2. Within vim, use :set makeprg=name_of_your_make_program to automatically compile from within vim with the :make command. As a bonus, if it's a toolset that vim recognizes, vim will parse the compiler's output, show you the errors, and allow you to jump to each of them so you can fix them. See the commands :cl, :cc, :cn, and :cp for starters.
like image 183
Adam Liss Avatar answered Oct 13 '22 20:10

Adam Liss