How to use MinGW make with Vim on Windows - vim

I have installed Vim and MinGW on my machine, so I try to create Hello World then compile in in Vim and everything work fine. However when I type :make it show error 'make' not recognized as an internal or external command.
I already added variable path to C:\MinGW\bin. I want to know how to configure Vim or my machine to allow make command.

Can you confirm that there is a make.exe in C:\MinGW\bin? I seem to remember that last time I installed mingw, it was called mingw32-make.exe.
If there is no make.exe but there is a mingw32-make.exe, you'll have to change the 'makeprg' option:
:set makeprg=mingw32-make
:make

Related

How to delete empty lines on visual studio code with the vim mode

I've been trying to delete many empty lines from a huge file. On other editors with vim, or vim itself, I could just do:
:%s/\n\n/\n/g
But neither if I use \r or \t it doesn't work. Seems like some vim features are missing on the editor. Is there any configuration to make that work or another way to do that?
To have advanced Vim functionality work within VScode, you can leverage its Neovim integration.
First, you'll have to install Neovim. For instructions, check out: https://github.com/neovim/neovim/wiki/Installing-Neovim
Then, adjust the following settings in your user configuration:
// Use neovim on backend. (only works for Ex commands right now). You should restart VScode after enable/disabling this for the changes to take effect. NOTE: Neovim must be installed (v0.2.0) and neovimPath must be set the executable in order for this setting to work. Otherwise, vscodevim will crash.
"vim.enableNeovim": true,
// Path to run neovim executable. For example, /usr/bin/nvim, or C:\Program Files\Neovim\bin\nvim.exe
"vim.neovimPath": "nvim",
Restart VScode. Now you can use Vim Ex commands, since the commands are sent to a headless Neovim instance that's running in the background. You can even use installed Vim plugin functions to a certain degree.

Vim using Syntastic plugin 'mpi.h' not found

I'm currently using Vim 7.4 on Ubuntu 16.04. I have the Syntastic plugin installed via pathogen.
I'm currently doing some coding in C using the mpi library. When I write my code using Vim, syntastic seems to believe that there is an error and tells me that "'mpi.h' file not found" (this is for #include <mpi.h>). I know that this program compiles as I'm able to run mpicc successfully.
When I run a locate mpi.h this is what I get back:
/usr/lib/openmpi/include/mpi.h
/usr/lib/openmpi/include/openmpi/ompi/mpi/fortran/mpif-h/prototypes_mpi.h
/usr/src/linux-headers-4.4.0-62/include/linux/mpi.h
/usr/src/linux-headers-4.4.0-66/include/linux/mpi.h
How can I get Vim to stop giving me these errors?
Create a file .syntastic_cpp_config in your project home folder.
Have all your include folders listed in it. In your case,
-I/usr/lib/openmpi/include
Or the other folder with mpi.h, whichever you use in your build.

How do I open Vim using Command?

I just downloaded and started using Vim so I'm still a bit confused with it. I've been watching tutorial videos and I see that I can open Vim by typing vim in command. However when I do it I get
'vim' is not recognized as an internal or external command, operable program or batch file
Did I need to install something else? Also I want to code and compile C in vim, would I need to install a compiler?
You have to invoke Vim (or gvim, the GUI application) with the full path, e.g.
"C:\Program Files\vim\vim74\vim.exe"
The Vim installer doesn't add the location to the PATH. In Windows, you can create a shortcut (*.lnk) in your Start Menu, or re-run "C:\Program Files\vim\vim74\install.exe", which has an option to install batch files to C:\Windows, or manually add "C:\Program Files\vim\vim74" to your PATH via the Control Panel.
Vim is just a (very advanced and powerful) text editor, so it ships with syntax highlighting for most programming languages, but unlike IDEs, it doesn't come with the full toolset of compiler, linker, debugger, etc. You need to separately install that (e.g. mingw, or Microsoft's compiler from the Windows SDK, or any other).
C:\>vim somefile.txt
During Vim (for Win32) install, you have the option to install batch files for launching vim from the command-line.
make sure you install vim properly. (https://www.vim.org/download.php)
On Windows. Don't forget to set the environment variables (simply add \vim\vim**; at the end of the classpath)
Type vim at command line (gvim.exe will start the Graphic user interface software).
If you want to compile and run c program using the command line, you should download the GCC Compiler and follow the same procedure as mentioned before (The classpath thing). Then you can compile C program using gcc command.

Compiling with gVim not working

I am trying to compile a simple C program to test that my set-up is correct.
First I typed it with gVim and created a Makefile
Now that I have a main.c and a Makefile, I tried compiling it by using
:make
Then I get this message:
|| 'make' is not recognized as an internal or external command,
|| operable program or batch file.
All of this under gVim.
Then to test that my makefile and make installation is working I opened Cygwin, went to the directory where my main and make files are, typed
$ make
And it compiled fine.
I am not really sure what to do next, I used to be able to run :make from gVim but that was a long time ago and I think I forgot how to set it up correctly.
I also have a portable gVim on my flash drive and on other computers with some other set up I can use
:make
from my own gVim.
All I needed to do was to add the PATH variables.
I feel stupid now.

make with vim using Intel Fortran

I have a project with Fortran and I use gvim as my editor. When I use gfortran as my compiler in my makefile, I encounter no problems. I also have a version of the makefile that uses intel fortran and that makefile also works fine when called from the terminal.
My problem is within gvim. Gfortran version of my makefile works great when called within vim with :make and it shows me the errors and jumps to them etc. However, when I use the ifort version, :make command in vim gives me an error saying he could not find ifort.
ifort works fine from the terminal. I have both ~/.bashrc and /etc/bash.bashrc edited so that it sources intel compilers. I use Crunchbang Waldorf (read: Debian Testing) and I remember having the same problem in LMDE.
Any help is greatly appreciated
Move PATH modifications from .bashrc//etc/bash/bashrc to .profile//etc/profile. This way you won’t need interactive shell like #ib. suggests (and, by the way, you need to do modifications to only one file, not both).
If your distribution uses /etc/env.d it may make sense to do
echo 'PATH=/path/to/ifc/binaries' >> /etc/env.d/99ifort
env-update
. But this should be distribution-specific.

Resources