Vim: Cierra Todos Los Búferes Excepto Éste
¿Cómo puedo cerrar todos los búferes en Vim excepto el que estoy editando actualmente?
11 answers
Puedes usar este script desde vim.org:
Http://www.vim.org/scripts/script.php?script_id=1071
Simplemente póngalo en su directorio .vim/plugin
y luego use el comando :BufOnly
para cerrar todos los búferes excepto el activo. También puede mapearlo en otro lugar que desee en su .vimrc
.
Fuente en Github (a través de vim-scripts mirror): https://github.com/vim-scripts/BufOnly.vim/blob/master/plugin/BufOnly.vim
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-17 08:08:14
Prueba esto
bufdo bd
Bufdo ejecuta el comando para todos los búferes
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-16 06:58:39
Si no te importa el actual, es más sencillo hacer algo como (sin necesidad de script):
1,100bd
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-17 16:55:19
Pude hacer esto muy fácilmente así:
:%bd|e#
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-06 15:50:40
Hago esto
:w | %bd | e#
Mi favorito si solo quiero que mi búfer actual se abra y cierre todos los demás.
Cómo funciona: primero escriba los cambios del búfer actual, luego cierre todos los búferes abiertos, luego vuelva a abrir el búfer en el que estaba actualmente. En Vim, el |
encadena la ejecución de órdenes. Si su búfer está actualizado, lo anterior se puede acortar a :%bd | e#
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-02 18:57:11
Basándonos en la respuesta de juananruiz.
Haga un pequeño cambio en el búfer que desea mantener, luego
:1,1000bd
El comando bd
(buffer delete) no eliminará ningún búfer con cambios no guardados. De esta manera puede mantener el archivo actual (cambiado) en la lista de búfer.
Editar: Tenga en cuenta que esto también eliminará su NERDTreeBuffer. Puedes recuperarlo con: NERDTree
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-06 09:02:51
Usando
:on[ly][!]
Y
:h only
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-09-07 13:03:10
Cerrando todos los búferes abiertos:
silent! execute "1,".bufnr("$")."bd"
Cerrando todos los búferes abiertos excepto el actual:
function! CloseAllBuffersButCurrent()
let curr = bufnr("%")
let last = bufnr("$")
if curr > 1 | silent! execute "1,".(curr-1)."bd" | endif
if curr < last | silent! execute (curr+1).",".last."bd" | endif
endfunction
Agregue esta función a .vimrc
y llámela usando :call CloseAllBuffersButCurrent()
.
Mapa de conveniencia:
nmap <Leader>\c :call CloseAllBuffersButCurrent()<CR>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-16 18:02:21
Hay plugin que hace exactamente esto y un poco más!
Echa un vistazo topes cerrados.vim
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-27 02:41:59
¿Qué tal solo:
Ctrl-w o
(gracias a https://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-11 01:19:21
Me gusta 1,100bd
(sugerido por juananruiz) que parece funcionar para mí.
Agregué un quit!
a mi mapeo para darme
nnoremap <leader>bd :1,100bd<CR>
nnoremap <leader>bdq :1,100bd<CR>:q!<CR>
Esto mata todos los búferes y apaga Vim, que es lo que estaba buscando en su mayoría.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:47:24