vim - 如何调出隐藏窗口?

浏览:38日期:2023-07-22

问题描述

vim test.htmlvsplit test.csssplit test.js

出现了三个窗口。

vim - 如何调出隐藏窗口?

光标移动到左下方,输入命令 :hide这样只有左右两个窗口了。

无论几个窗口,右侧的test.html不变,我这样切换:1。在保持只有两个窗口的状态下使用 e test.css 调出刚才隐藏的这个test.css窗口2。三个窗口下,使用 split test.css调出刚才隐藏的这个test.css窗口

感觉不是最快捷的切换方法。

问题解答

回答1:第一种方式:

可以配合你的使用习惯配置一些VIM的alias

比如可以把split 改成sp

nmap split sp第二种方式:

通过方式是通过mapleader,配置自己习惯的map组合键完成

vim - 如何调出隐藏窗口?

比如我的就是通过快捷键

ff + l // 光标移到左边一个窗口ff + h // 光标移到右边边一个窗口ff + q // 关闭当前窗口打开的文件

call pathogen#infect()let mapleader = 'ff'set nocompatibleset nomodelineset viminfo=’1000,f1,:1000,/1000set history=1000let pair_program_mode = 0'------ Charset Init ------scriptencoding utf-8set encoding=utf-8'------ Visual Options ------syntax onset numberset nowrapset vbset rulerset statusline=%<%f %h%m%r%=%{fugitive#statusline()} %-14.(%l,%c%V%) %Plet g:buftabs_only_basename=1let g:buftabs_marker_modified = '+'' Toggle whitespace visibility with ,snmap <Leader>s :set list!<CR>set listchars=tab:▸ ,trail:·,extends:❯,precedes:❮,nbsp:×:set list ' Enable by default' <Leader>L = Toggle line numbersmap <Leader>L :set invnumber<CR>' New splits open to right and bottomset splitbelowset splitright'------ Generic Behavior ------set tabstop=4set shiftwidth=4set hiddenfiletype indent onfiletype plugin onset autoindent'allow deletion of previously entered data in insert modeset backspace=indent,eol,start' Allow saving of files as sudo when I forgot to start vim using sudo.cmap w!! %!sudo tee > /dev/null %' F2 = Paste Toggle (in insert mode, pasting indented text behavior changes)set pastetoggle=<F2>' The search for the perfect color scheme...map <silent> <Leader>x :RandomColorScheme<CR>' <Leader>v = Pastemap <Leader>v '+gP' <Leader>c = Copymap <Leader>c '+y' Accidentally pressing Shift K will no longer open stupid man entrynoremap K <nop>' Edit and Reload .vimrc filesnmap <silent> <Leader>ev :e $MYVIMRC<CR>nmap <silent> <Leader>es :so $MYVIMRC<CR>' When pressing <Leader>cd switch to the directory of the open buffermap ,cd :cd %:p:h<CR>' Wtf is Ex Mode anyways?nnoremap Q <nop>' Annoying windowmap q: :q'------ Text Navigation ------' Prevent cursor from moving to beginning of line when switching buffersset nostartofline' Keep the cursor in place while joining linesnnoremap J mzJ`z' H = Home, L = Endnoremap H ^noremap L $vnoremap L g_'------ Window Navigation ------' <Leader>hljk = Move between windowsnnoremap <Leader>h <C-w>hnnoremap <Leader>l <C-w>lnnoremap <Leader>j <C-w>jnnoremap <Leader>k <C-w>k'<Leader>= = Normalize window widthsnnoremap <Leader>= :wincmd =<CR>'------ Buffer Navigation ------' Ctrl Left/h & Right/l cycle between buffersnoremap <silent> <C-left> :bprev<CR>noremap <silent> <C-h> :bprev<CR>noremap <silent> <C-right> :bnext<CR>noremap <silent> <C-l> :bnext<CR>' <Leader>q Closes the current buffernnoremap <silent> <Leader>q :Bclose<CR>' <Leader>Q Closes the current windownnoremap <silent> <Leader>Q <C-w>c' <Leader>Ctrl+q Force Closes the current buffernnoremap <silent> <Leader><C-q> :Bclose!<CR>'------ Searching ------set incsearchset ignorecaseset smartcaseset hlsearch' Clear search highlights when pressing <Leader>bnnoremap <silent> <leader>b :nohlsearch<CR>' http://www.vim.org/scripts/script.php?script_id=2572' <Leader>a will open a prmompt for a term to search fornoremap <leader>a :Ack ' <Leader>A will close the new window created for that ack searchnoremap <leader>A <C-w>j<C-w>c<C-w>llet g:ackprg='ag --vimgrep --column'' CtrlP will load from the CWD, makes it easier with all these nested reposlet g:ctrlp_working_path_mode = ’’' CtrlP won’t show results from node_moduleslet g:ctrlp_custom_ignore = ’v[/](node_modules|coverage|target|dist)|(.(swp|ico|git|svn|png|jpg|gif|ttf))$’'type S, then type what you’re looking for, a /, and what to replace it withnmap S :%s//g<LEFT><LEFT>vmap S :s//g<LEFT><LEFT>'------ NERDTree Options ------let NERDTreeIgnore=[’CVS’,’.dSYM$’, ’.git’, ’.DS_Store’, ’.swp$’, ’.swo$’]'setting root dir in NT also sets VIM’s cdlet NERDTreeChDirMode=2' Toggle visibility using <Leader>nnoremap <silent> <Leader>n :NERDTreeToggle<CR>' Focus on NERDTree using <Leader>mnoremap <silent> <Leader>m :NERDTreeFocus<CR>' Focus on NERDTree with the currently opened file with <Leader>Mnoremap <silent> <Leader>M :NERDTreeFind<CR>' These prevent accidentally loading files while focused on NERDTreeautocmd FileType nerdtree noremap <buffer> <c-left> <nop>autocmd FileType nerdtree noremap <buffer> <c-h> <nop>autocmd FileType nerdtree noremap <buffer> <c-right> <nop>autocmd FileType nerdtree noremap <buffer> <c-l> <nop>' Open NERDTree if we’re executing vim without specifying a file to openautocmd vimenter * if !argc() | NERDTree | endif' Hides 'Press ? for help'let NERDTreeMinimalUI=1' Shows invisibleslet g:NERDTreeShowHidden=1'------ Fugitive Plugin Options ------'https://github.com/tpope/vim-fugitivennoremap <Leader>gs :Gstatus<CR>nnoremap <Leader>gr :Gremove<CR>nnoremap <Leader>gl :Glog<CR>nnoremap <Leader>gb :Gblame<CR>nnoremap <Leader>gm :Gmove nnoremap <Leader>gp :Ggrep nnoremap <Leader>gR :Gread<CR>nnoremap <Leader>gg :Git nnoremap <Leader>gd :Gdiff<CR>'------ Text Editing Utilities ------' <Leader>T = Delete all Trailing space in filemap <Leader>T :%s/s+$//<CR>' <Leader>U = Deletes Unwanted empty linesmap <Leader>U :g/^$/d<CR>' <Leader>R = Converts tabs to spaces in documentmap <Leader>R :retab<CR>'------ JSON Filetype Settings ------au BufRead,BufNewFile *.json set filetype=jsonlet g:vim_json_syntax_conceal = 0nmap <silent> =j :%!python -m json.tool<CR>:setfiletype json<CR>autocmd BufNewFile,BufRead *.webapp set filetype=jsonautocmd BufNewFile,BufRead *.jshintrc set filetype=jsonautocmd BufNewFile,BufRead *.eslintrc set filetype=json'------ CoffeeScript Filetype Settings ------au BufNewFile,BufReadPost *.coffee set shiftwidth=2 softtabstop=2 expandtabautocmd BufNewFile,BufRead *.coffee set filetype=coffeeau BufWritePost *.coffee silent make!autocmd QuickFixCmdPost * nested cwindow | redraw!'------ JSX Filetype Settings ------autocmd! BufEnter *.jsx let b:syntastic_checkers=[’eslint’]autocmd! BufEnter *.js let b:syntastic_checkers=[’eslint’]'------ EJS Filetype Settings ------au BufNewFile,BufRead *.ejs set filetype=html'------ SCSS Filetype Settings ------autocmd FileType scss set iskeyword+=-'------ Markdown Settings ------let g:vim_markdown_folding_disabled = 1'------ Airline Settings ------let g:airline_left_sep=’’let g:airline_right_sep=’’let g:airline#extensions#tabline#enabled = 1let g:airline#extensions#tabline#left_sep = ’ ’let g:airline#extensions#tabline#left_alt_sep = ’ ’'------ GUI Options ------if has('gui_running') ' Hides toolbar and scrollbars and File menu set guioptions=egt ' Highlights the current line background set cursorline colorscheme hybrid 'autocmd VimEnter * TagbarOpen ' Open VIM in fullscreen window set lines=200 columns=500 ' Toggle fullscreen map <silent> <leader>w :set lines=200 columns=500<CR> ' Build all help tags (slower launch, but I run GUI vim like once per day) call pathogen#helptags() silent! cd $HOME/Projects if has('gui_macvim') ' OS X'set guifont=Monaco:h14set guifont=Monaco:h10set noantialias'set transparency=15' Swipe to move between bufers :Dmap <silent> <SwipeLeft> :bprev<CR>map <silent> <SwipeRight> :bnext<CR>' Cmd+Shift+N = new buffermap <silent> <D-N> :enew<CR>' Cmd+P = CtrlP' TODO: This doesn’t actually work, still opens Print dialogmacmenu File.Print key=<nop>nnoremap <silent> <D-p> :CtrlP<CR>' Cmd+t = new tabnnoremap <silent> <D-t> :tabnew<CR>' Cmd+w = close tab (this should happen by default)nnoremap <silent> <D-w> :tabclose<CR>' Cmd+1...9 = go to that tabmap <silent> <D-1> 1gtmap <silent> <D-2> 2gtmap <silent> <D-3> 3gtmap <silent> <D-4> 4gtmap <silent> <D-5> 5gtmap <silent> <D-6> 6gtmap <silent> <D-7> 7gtmap <silent> <D-8> 8gtmap <silent> <D-9> 9gt' OS X probably has ctags in a weird placelet g:tagbar_ctags_bin=’/usr/local/bin/ctags’' Damn you scrollwheel pastennoremap <MiddleMouse> <Nop>nnoremap <2-MiddleMouse> <Nop>nnoremap <3-MiddleMouse> <Nop>nnoremap <4-MiddleMouse> <Nop>inoremap <MiddleMouse> <Nop>inoremap <2-MiddleMouse> <Nop>inoremap <3-MiddleMouse> <Nop>inoremap <4-MiddleMouse> <Nop>' Pair Program mode, so that my coworkers can read my screen ;)nnoremap <leader>p :call PairProgramMode()<cr>function! PairProgramMode() if g:pair_program_modelet g:pair_program_mode = 0set guifont=Monaco:h10set noantialiasset lines=200 columns=500 elseset guifont=Monaco:h15set antialiasset lines=200 columns=500let g:pair_program_mode = 1 endifendfunction elseif has('gui_gtk2') ' Linuxset guifont=monospace 9' Alt+n = new buffermap <silent> <A-n> :enew<CR>' Alt+t = new tabnnoremap <silent> <A-t> :tabnew<CR>' Alt+w = close tabnnoremap <silent> <A-w> :tabclose<CR>' Alt+1...9 = go to that tabmap <silent> <A-1> 1gtmap <silent> <A-2> 2gtmap <silent> <A-3> 3gtmap <silent> <A-4> 4gtmap <silent> <A-5> 5gtmap <silent> <A-6> 6gtmap <silent> <A-7> 7gtmap <silent> <A-8> 8gtmap <silent> <A-9> 9gt elseif has('gui_win32') ' Windows' WHAT ARE YOU DOING WITH YOUR LIFE?! endifelse set t_Co=256 colorscheme Mustang set mouse=aendif'------ Local Overrides ------if filereadable($HOME.’/.vimrc_local’) source $HOME/.vimrc_localendif

相关文章: