2

The problem is that I need to pass include paths to the C++ compiler. I can define them for each buffer, like:

:let b:COMPILER_OPTIONS='-ggdb -I"E:\boost_1_42_0\boost\"'

But how do I expand b:COMPILER_OPTIONS on the command line ?

:!g++ program.cpp eval('b:COMPILER_OPTIONS')

doesn't work.

Or, if this isn't possible, what other ways are there for doing this ?

1
  • Do you want the path to the current file? if so, I believe it's % Commented Mar 26, 2010 at 2:40

1 Answer 1

4

I don't think you can do it directly, but you can define a custom command:

:command! -nargs=1 Gpp exe '!g++' b:COMPILER_OPTIONS '<args>'

if you want filename completion you can add the -complete option:

:command! -nargs=1 -complete=file Gpp exe '!g++' b:COMPILER_OPTIONS '<args>'

usage:

:Gpp program.cpp
Sign up to request clarification or add additional context in comments.

1 Comment

directly would just be :exe '!g++' b:COMPILER_OPTIONS 'program.cpp'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.