Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to call :make in vim in linux without showing the shell

Tags:

I've been trying to experiment with using :make recently but I don't like that vim has to switch to showing the shell output first and require one enter keypress, then it shows me what I think is a list of the collected errors based on 'errorformat' which I also need to confirm by pressing enter. I would prefer to just have a short "OK" message that does not require confirmation by a keypress, or that vim would open the :cwindow if there were any errors.

like image 608
Sam Avatar asked Jul 06 '09 20:07

Sam


People also ask

How to get a shell from Vim?

You can run commands in Vim by entering the command mode with : . Then you can execute external shell commands by pre-pending an exclamation mark ( ! ). For example, type :! ls , and Vim will run the shell's ls command from within Vim.

How to run from Vim?

Launching Vim In order to launch Vim, open a terminal, and type the command vim . You can also open a file by specifying a name: vim foo. txt .

How to use unix commands in Vim?

Go to command mode Esc , then run :! unix_command . Anything run from the : prompt starting with a bang ! will be run as a unix shell command. You'll be shown the output and allowed to hit a key to get back to your work in vim.


2 Answers

I'm using next line just for exact purpose you wrote:

nnoremap <leader>m :silent make\|redraw!\|cc<CR> 

cc in the end shows first error or No errors message if this is the case.

like image 131
nshy Avatar answered Sep 20 '22 17:09

nshy


You can map for example F9 to use gcc for small C snippets that don't require libraries, linking, etc:

map <F9> :!gcc -o %< % <enter><CR><C-w> 

This will produce for the file foo.c the binary foo. I know that's not exactly what you want, but this doesn't show any shell and is useful for small c snippet.

like image 22
Fatih Arslan Avatar answered Sep 16 '22 17:09

Fatih Arslan