最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ide - "zsh:1: no such file or directory" when trying to use :CompileRun in Vim - Stack Overflow

programmeradmin2浏览0评论

I just started to use Vim as my main IDE and set up some plugins like syntastic. But when I try to compile and run my program inside Vim by the :CompileRun command, I get this error:

zsh:1: no such file or directory:.//mnt/Storage/C++/EX/test.cpp

Here is my .vimrc:

set number

call plug#begin('~/.vim/plugged')

Plug 'preservim/nerdtree'                             
Plug 'airblade/vim-gitgutter'                         
Plug 'scrooloose/nerdcommenter'                       
Plug 'vim-airline/vim-airline'                         
Plug 'vim-airline/vim-airline-themes'                  
Plug 'ycm-core/YouCompleteMe'                         
Plug 'tmux-plugins/vim-tmux', { 'branch': 'master' }
Plug '[email protected]:cpp0x/vim-cpp-modern.git'                            

Plug 'vim-syntastic/syntastic'
command! CompileRun execute './"%:p:r".out'


" Enable clangd for C++ support (for autocompletion, diagnostics)
let g:coc_global_extensions = ['coc-clangd']
let g:syntastic_mode_map = { 'mode': 'active' }
let g:syntastic_cpp_checkers = ['gcc']


call plug#end()

And I tried to replace the command! line with the correct one and tried multiple things, but it didn't work.

I just started to use Vim as my main IDE and set up some plugins like syntastic. But when I try to compile and run my program inside Vim by the :CompileRun command, I get this error:

zsh:1: no such file or directory:.//mnt/Storage/C++/EX/test.cpp

Here is my .vimrc:

set number

call plug#begin('~/.vim/plugged')

Plug 'preservim/nerdtree'                             
Plug 'airblade/vim-gitgutter'                         
Plug 'scrooloose/nerdcommenter'                       
Plug 'vim-airline/vim-airline'                         
Plug 'vim-airline/vim-airline-themes'                  
Plug 'ycm-core/YouCompleteMe'                         
Plug 'tmux-plugins/vim-tmux', { 'branch': 'master' }
Plug '[email protected]:cpp0x/vim-cpp-modern.git'                            

Plug 'vim-syntastic/syntastic'
command! CompileRun execute './"%:p:r".out'


" Enable clangd for C++ support (for autocompletion, diagnostics)
let g:coc_global_extensions = ['coc-clangd']
let g:syntastic_mode_map = { 'mode': 'active' }
let g:syntastic_cpp_checkers = ['gcc']


call plug#end()

And I tried to replace the command! line with the correct one and tried multiple things, but it didn't work.

Share Improve this question asked Jan 30 at 11:23 elenntarelenntar 111 silver badge4 bronze badges 2
  • FYI, Syntastic was deprecated 3 years ago. Its deprecation note suggests to use ALE. – Friedrich Commented Jan 30 at 19:09
  • Anyhow, what is :execute <file> supposed to do? The :execute command takes an expr, not a file. If you're trying to run something, you miss at least a !. – Friedrich Commented Jan 31 at 6:34
Add a comment  | 

1 Answer 1

Reset to default 2

The error is in './"%:p:r".out': %:p returns full path from the root of the filesystem, but you prepend ./ and spoiled the full path. Just remove ./:

command! CompileRun execute '"%:p:r".out'
发布评论

评论列表(0)

  1. 暂无评论