0

I'm new to vim and apologize if the question seems redundant, but I couldn't find a suitable answer.

I have a shell script compile.sh that I would like to run each time I press some key (say, F8) on my vim, but I want this keybinding to be specific to my projects since other projects don't necessarily have that shell script.

Alternative solution would be to just hardcode if statements on my shell script with the path of my project, but I'm wondering if there are other ways by rewriting vimrc.

Edit: here's my compile.sh:

cd ~/projects/lnxdbg/
cmake -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -S . -B build/
cd build/
make
1
  • 2
    You might be looking for some sort of local vimrc type thing, of which there are plenty (e.g., have a look at vi.stackexchange.com/q/77/10604). Please edit to explain what you are looking for in more detail. I also strongly encourage you to read about :make/:terminal, which are great commands for running compilers. :make is especially nice after :compiler or setting 'makeprg'/'errorformat'. Then you can have a single key-binding to run :make and simply set the appropriate options for each project.
    – D. Ben Knoble
    Aug 14 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.