Closed paraduxos closed 4 years ago
concatinate commands with &&:
:AsyncRun command1 && command2
Thank you. This is what I did.
" create directory {cwd/object_files}
function! MakeObjectDir()
" if not yet created
if !isdirectory(expand("%:p:h") . '/object_files')
call mkdir(expand("%:p:h") . '/object_files', 'p')
echo "Created directory:\n" . expand("%:p:h") . '/object_files'
else
echo "Directory already exist:\n" . expand("%:p:h") . "/object_files"
endif
endfunction
" run function before compile
nnoremap <silent> <leader>2 :call MakeObjectDir() <cr> <bar> :AsyncRun g++ -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/object_files/$(VIM_FILENOEXT)" <cr>
nnoremap <silent> <leader>3 :AsyncRun -mode=term -pos=right -cwd=$(VIM_FILEDIR) "$(VIM_FILEDIR)/object_files/$(VIM_FILENOEXT)" <cr>
concatinate commands with &&:
:AsyncRun command1 && command2
请问大佬,我使用neovim
,想实现用一个命令完成「编译并运行」这个功能,该怎么写呢?
我试过:AsyncRun -save=1 g++ $(文件名) -o $(文件).exe && (:AsyncRun这个括号的内容加不加都一样) -mode=term -pos=right $(文件).exe
,十分可惜不起作用。
如果使用autocmd User AsyncRunStop func
的话,会导致其他AsyncRun
命令结束后也使用了这里的函数,这就会造成很多困扰。
谢谢!
:AsyncRun -save=1 g++ $(VIM_FILEPATH) -o $(VIM_PATHNOEXT).exe && $(VIM_PATHNOEXT).exe
:AsyncRun -save=1 g++ $(VIM_FILEPATH) -o $(VIM_PATHNOEXT).exe && $(VIM_PATHNOEXT).exe
可惜这样只能在quickfix
里显示输出,但我需要很多无法事先确定内容的输入,所以添加了-mode=term
选项。
自己写个脚本调用下呗。
你还可以测试下:
let g:asyncrun_term_safe = 1
使用安全传参方式。
你还可以测试下:
let g:asyncrun_term_safe = 1
使用安全传参方式。
还是无法在终端中打开并输入,我还是去研究研究脚本该怎么写吧,麻烦大佬了
This is my current
neovim
commandHow to create one subdirectory (if not exist) and save there, for instance: