Zamknąć plik bez zamykania aplikacji VIM?
Jestem nowy w Vimie. Używam komend :e
i :w
do edycji i zapisu pliku, które są bardzo wygodne. Nie jestem pewien, czy istnieje polecenie "close", aby zamknąć bieżący plik bez opuszczania Vima?
Wiem, że polecenie :q
może być użyte do zamknięcia pliku, ale jeśli jest to ostatni plik, VIM jest również zamknięty; w rzeczywistości na Mac OS MacVIM kończy pracę. Tylko okno Vima jest zamknięte i mogłem użyć Control - N, aby ponownie otworzyć pusty VIM. Chciałbym, aby VIM pozostał otwarty z pustym ekran.
11 answers
Usuwa bufor (co tłumaczy zamknięcie pliku)
:bd
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-11-01 22:37:59
Jak już wspomniano, szukasz : bd , jednak to nie całkowicie usuwa bufor, nadal jest dostępny:
:e foo
:e bar
:buffers
1 #h "foo" line 1
2 %a "bar" line 1
Press ENTER or type command to continue
:bd 2
:buffers
1 %a "foo" line 1
Press ENTER or type command to continue
:b 2
2 bar
Możesz zamiast tego chcieć : bw, który całkowicie go usuwa.
:bw 2
:b 2
E86: Buffer 2 does not exist
Niewiedza o : bw przez jakiś czas mnie podsłuchiwała.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-12-02 11:13:34
Jeśli masz wiele podzielonych okien w oknie Vima, to: bd zamyka Dzielone okno bieżącego pliku... więc lubię używać czegoś bardziej zaawansowanego:
map fc <Esc>:call CleanClose(1)
map fq <Esc>:call CleanClose(0)
function! CleanClose(tosave)
if (a:tosave == 1)
w!
endif
let todelbufNr = bufnr("%")
let newbufNr = bufnr("#")
if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr))
exe "b".newbufNr
else
bnext
endif
if (bufnr("%") == todelbufNr)
new
endif
exe "bd".todelbufNr
endfunction
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-11-14 13:41:08
:[N]bd[elete][!] *:bd* *:bdel* *:bdelete* *E516* :bd[elete][!] [N] Unload buffer [N] (default: current buffer) and delete it from the buffer list. If the buffer was changed, this fails, unless when [!] is specified, in which case changes are lost. The file remains unaffected. Any windows for this buffer are closed. If buffer [N] is the current buffer, another buffer will be displayed instead. This is the most recent entry in the jump list that points into a loaded buffer. Actually, the buffer isn't completely deleted, it is removed from the buffer list |unlisted-buffer| and option values, variables and mappings/abbreviations for the buffer are cleared.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-11-01 22:39:16
Jeśli zapisałeś już ostatni plik, to: enew jest twoim przyjacielem (: enew! jeśli nie chcesz zapisać ostatniego pliku). Zauważ, że oryginalny plik nadal będzie na twojej liście buforów (ten dostępny przez :ls).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-11-01 22:37:33
Jeśli zmodyfikujesz plik i chcesz go zamknąć bez zamykania Vima i bez zapisywania, powinieneś wpisać :bd!
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-13 13:38:02
:bd można mapować. Mapuję go do F4, shift-F4 jeśli muszę wymusić zamknięcie z powodu jakiejś zmiany, której już nie chcę.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-03-27 21:40:29
Jest do tego plugin: bufkill (Zobacz http://www.vim.org/scripts/script.php?script_id=1147 )
To dodaje BD
itd, aby usunąć bufor bez zamykania żadnych podziałów (jak tylko bd
).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-09-21 13:03:17
Zmapowałem bd do F4 z Wstaw ten link u siebie .plik vimrc i po naciśnięciu F4 zamknie bieżący plik.
:map <F4> :bd<CR>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-31 14:40:36
Spójrz na wtyczkę Butan, aby zachować układ okna podczas zamykania bufora.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-05-07 10:27:34
Mam ten sam problem, więc zrobiłem wtyczkę. Ta wtyczka zastępuje: q i inne polecenia, a następnie zapobiega zamknięciu okna.
Jeśli nadal masz problem, spróbuj użyć poniższej wtyczki. https://github.com/taka-vagyok/prevent-win-closed.vim
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-27 21:37:17