'How can I set path of vim from the shell command result
I'd like to set c++ header file path automatically from .vimrc. So I tried to write .vimrc file as shown below:
let g:gcpp_headers_path=system("g++ --version | grep g++ | awk '{print \"/usr/include/c++/\"$NF}'")
"if isdirectory(gcpp_headers_path)
set path+=g:gcpp_headers_path
"endif
from the vimrc above I found the vim variable path set as shown below:
:set path?
path=.,/usr/include,,,g:gcpp_headers_path
The wanted output is as shown below:
:set path?
path=.,/usr/include,/usr/include/c++/7.5.0
I'd like to get this reviewed. Could someone advise me?
F.Y.I. The command in system() is shown below:
~$ g++ --version | grep g++ | awk '{print "/usr/include/c++/"$NF}'
/usr/include/c++/7.5.0
For documentation I am writing my answer found here:
let g:gcpp_headers_path = system("g++ --version | grep g++ | awk '{print \"/usr/include/c++/\"$NF}'")
execute 'set path+=' . g:gcpp_headers_path
My vim version is Vi IMproved 8.0 (2016 Sep 12, compiled Jan 20 2022 02:47:53)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
