我把窗户横着分开了。现在我如何回到正常模式,即没有分裂窗口,只有一个窗口,而不取消所有打开的窗口。我有5个,并不想“退出”,只是想从分裂的窗口出去。
当前回答
关闭除当前窗口外的所有窗口:
CTRL + w, o
也就是说,先按CTRL+w,再按o。
其他回答
我很好地理解了你的意图,我也专门使用缓冲区,如果需要,偶尔也会进行分割。
下面是我的.vimrc的节选
" disable macro, since not used in 90+% use cases
map q <Nop>
" q, close/hide current window, or quit vim if no other window
nnoremap q :if winnr('$') > 1 \|hide\|else\|silent! exec 'q'\|endif<CR>
" qo, close all other window -- 'o' stands for 'only'
nnoremap qo :only<CR>
set hidden
set timeout
set timeoutlen=200 " let vim wait less for your typing!
这非常适合我的工作流程
如果按下q 隐藏当前窗口,如果多个窗口打开,否则尝试退出vim。 如果按qo键, 关闭所有其他窗口,如果只有一个窗口没有效果。
当然,您可以将这一混乱的部分封装到一个函数中,例如
func! Hide_cur_window_or_quit_vim()
if winnr('$') > 1
hide
else
silent! exec 'q'
endif
endfunc
nnoremap q :call Hide_cur_window_or_quit_vim()<CR>
旁注: 我重新映射q,因为我不使用宏进行编辑,而是使用:s,:g,:v,如果需要,和外部文本处理命令,例如:'{,'}!Awk 'some_programm',或者使用:norm!normal-command-here。
关闭当前窗口的两个备选选项是ZZ和ZQ,它们将分别保存和不保存对显示缓冲区的更改。
help open -window(搜索" close a window" - / close a window)
:q[uit] close the current window and buffer. If it is the last window it will also exit vim :bd[elete] unload the current buffer and close the current window :qa[all] or :quita[ll] will close all buffers and windows and exit vim (:qa! to force without saving changes) :clo[se] close the current window but keep the buffer open. If there is only one window this command fails :hid[e] hide the buffer in the current window (Read more at :help hidden) :on[ly] close all other windows but leave all buffers open
按Control+w,然后按q一次关闭每个窗口。
更新:也考虑eckes的答案,这可能对你更有用,包括:on(阅读下面),如果你不想一次只做一个窗口。
提供窗口号以关闭特定窗口而不保留当前窗口:
:[N]close
:close[N]
:[N]quit
:quit[N]
Ctrl-W[N]c
窗口号可以通过以下设置显示在状态行中:
:set statusline+=%{tabpagewinnr(tabpagenr())}
推荐文章
- 如何在可视块模式插入?
- 强迫自己掌握vi的最好方法是什么?
- 如何回到行之前编辑的最后一个在Vim?
- 如何跳转到一个特定的人物在vim?
- 如何删除一个大的文本块而不计算行?
- Java中的split()方法对点(.)不起作用。
- 在Vim/Vi中,如何将光标移动到前一个单词的末尾?
- 如何在vim中自动删除尾随空格
- 为什么Vim使用~扩展名保存文件?
- 如何在Vim或Linux中将空格转换为制表符?
- 我如何使用vimdiff来解决git合并冲突?
- 在Vim中删除当前缓冲区的文件名/路径
- Git在终端提交时打开VIM,但无法返回终端
- 请参阅编辑器中的换行符和回车
- 如何在NERDTree中显示隐藏文件(以句点开始)?