求助:Vim中:make命令执行结果显示异常(内容不全、窗口被覆盖)
:make Issues in Vim (For Newbies) Hey there! As someone who fumbled through Vim's :make command when I was just starting out, I totally get how confusing these problems are—disappearing content, half-hidden output, and needing to press e just to get back to your code? Ugh, been there. Let's fix this step by step:
Why your content seems to vanish (and how to stop it)
When you run :make, Vim's default move is to jump straight to the first error it finds. If that error's in a random line of your file (or even a different file), it feels like your original code just disappeared—you're actually just looking at the error location!
To stay right where you are instead of jumping around, add these lines to your ~/.vimrc (or %USERPROFILE%/_vimrc if you're on Windows):
" Keep cursor in your current position when running :make set nojump " Automatically open the window showing all make output autocmd QuickFixCmdPost * cwindow
That autocmd line is key—it'll pop up a small window at the bottom of your Vim screen with the full make results, so you never have to guess what happened.
Getting full :make output every time
The incomplete output you're seeing is almost definitely because Vim isn't showing you the quickfix window (where all the compile messages live) by default. The autocmd I just mentioned fixes that, but if you don't want to edit your config right now, you can manually open the quickfix window after running :make by typing :copen. Boom—full output, no more guessing.
Ditching the "press e to restore" weirdness
That annoying part where you have to hit e to get your code back? It's because Vim's trying to jump to an error preview without showing you the proper prompts. The set nojump line stops that auto-jump, and the quickfix window gives you all the error info upfront instead of making you hunt for it.
One more quick check: make sure your Vim isn't hiding important messages. Reset your shortmess setting to something friendlier with this line in your vimrc:
set shortmess=filnxtToOFc
This keeps useful prompts visible so you won't be left scratching your head wondering what Vim wants from you.
Quick beginner tips for :make
- After running
:make, use:cnextand:cprevto cycle through errors in the quickfix window. - Jump straight to an error from the quickfix window by moving your cursor to that line and pressing Enter.
- Close the quickfix window anytime with
:cclose.
内容的提问来源于stack exchange,提问作者scewps

