Closed InViz101 closed 3 years ago
Close! You have the right idea, but the %:r
scheme is expanded by expand()
, not printf()
. Hence, you would need to use the following:
command! -nargs=0 CompileAndRun call TermWrapper(printf('g++ -std=c++17 %s -o %s && ./%s', expand('%'), expand('%:r'), expand('%:r')))
Let me know if that works!
apologies for late reply got busy in academics. i was getting the following error
zsh:1: no such file or directory: .//Users/username/lcpp/ex1/ex1
so i changed ./%s
in 'g++ -std=c++17 %s -o %s && ./%s'
to 'g++ -std=c++17 %s -o %s && %s'
now the requested feature works .
i was trying to implement it without knowing anything about UNIX command-line and vim so i have started going through respective documentations , thank you.
Glad to hear it works. Going through the documentation is definitely an important and rewarding step of the learning process!
Cheers, Michael
On Sat, Nov 20, 2021 at 1:16 PM InViz101 @.***> wrote:
apologies for late reply got busy in academics. i was getting the following error
zsh:1: no such file or directory: .//Users/username/lcpp/ex1/ex1
so i changed ./%s in 'g++ -std=c++17 %s -o %s && ./%s' to 'g++ -std=c++17 %s -o %s && %s'
now the requested feature works .
i was trying to implement it without knowing anything about UNIX command-line and vim so i have started going through respective documentations , thank you.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mizlan/vim-and-cp/issues/5#issuecomment-974712505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKSBU2LA64E2Y4BEJDUXH6TUNAF37ANCNFSM5IAKCOBQ .
command! -nargs=0 CompileAndRun call TermWrapper(printf('g++ -std=c++11 %s && ./a.out', expand('%')))
how to edit above command so that it produces executable file with same name and run it with TermWrapper ?
i tried the following but it results in a excutable file with "/r" name in home directory and run via termwrapper
command! -nargs=0 CompileAndRun call TermWrapper(printf('g++ -std=c++17 %s -o %:r && ./%:r', expand('%')))
operating system : mac BigSur editor : NVIM v0.6.0-dev+513-ga5d6f36fc