views:

74

answers:

2

Hi, I want to learn Vim editor and I'm trying to compile a C file. I've installed MinGW and I've added gcc.exe to System Path:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Arquivos de programas\TortoiseSVN\bin;c:\Arquivos de programas\Microsoft SQL Server\100\Tools\Binn\;c:\Arquivos de programas\Microsoft SQL Server\100\DTS\Binn\;C:\MinGW\bin\

Within Vim, I did: :!gcc code.c -o gcc.exe A cmd window open with the following text:

C:\WINDOWS\system32\cmd.exe /c gcc -Wall code.c -o code.exe
gcc: code.c: No such file or directory
gcc: no input files
shell returned 1
Hit any key to close this window...

What's wrong? Thank you.

+2  A: 

See this question for full .vimrc, the line you need is:

" Automatically cd into the directory that the file is in
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
Igor Klimer
Pretty cool. It's really working! Thank you! Can you explain this line?
gazu
Actually... no :) I didn't bother with it, I just used it - but `:help` is your friend, the `autocmd` command is covered in `40.3`
Igor Klimer
Ok, thank you very much.
gazu
A: 

Is it possible that your file is actually named "code.c.something". Windows likes to add extra endings to files without asking. This is probably not the solution, but it's something to watch out for.

luther07
Where did you get the idea that Windows likes to do that?
ysap
Default-style settings in Windows will hide file extensions and automatically add file extensions when you save a file. If you allow all file extensions to be hidden, then you don't know the names of your files.
luther07