2015-08-28 49 views
1

TOHtml到HTML可用於將文件轉換爲HTML,但它也將創建一個新文件。例如,如果原來的文件名是test,VIM將創建一個新的文件名爲test.html轉換文件到位

是否有修改的地方文件的方法,即只是轉換test爲HTML,而不是創建一個新的文件?

回答

4

:TOhtml創建新的緩衝區。它不保存它,所以它不會創建一個新的文件。您可以利用這樣一個事實:

" create test.html buffer 
:TOhtml 
" change back to test buffer 
:b test 
" destroy it, because we can't save another buffer with this name 
" while this one is open 
:bd 
" switch back to test.html (if you had no other buffers, this is likely unnecessary) 
:b test.html 
" save it, overwriting the original 
:w test 

編輯:我相信這是更短,同時還在做同樣的:

:TOhtml 
:bd test 
:w test