[20230206]vim diff 小技巧.txt
[20230206]vim diff 小技巧.txt
--//昨天看了一個vim diff小技巧,在編輯過程中看看改動那些.
--//連結:
7: Show diff before saving the file
We have all been there. "I modified this file, but don't know what I changed and now I am afraid the change will cause
unexpected issues down the road."
The remedy to this problem is to view the difference between the buffer and the file.
To do so, execute the following command in Vim itself:
:w !diff % -
Let's break this down so you understand what is happening...
:w is the Vim command to save/write. In this particular scenario, where no file name is specified in the command,
the output is written to the STDIN (standard input) file.
:!<command> is the syntax for executing a shell command. In our case, we are running the diff command in our shell.
% represents the name of the current file that is unmodified. Try this with :!echo %.
- is the STDIN file for the diff command.
So, this command first writes all the [unsaved] content to the STDIN file. Then the diff command reads the current file
(%) and comparing it against the STDIN (-) file.
This command roughly equates to this shell command -> diff <original-file> <Vim's STDOUT>.
--//in windows , because space ,use "%" 代替 % ,注意w ! 之間存在空格,不然建立一個人新檔案"dff -Nur".
:w !diff -Nur "%" -
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2934659/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20180417]vim小技巧.txt
- [20181019]vim小技巧刪除製表符.txt
- [20200224]vim小技巧刪除製表符2.txt
- [20210106]vim syntax txt.vim.txt
- [20230206]整理awr佔用空間3.txt
- [20210207]bash history小技巧.txt
- [20181219]script使用小技巧.txt
- [20231030]kitty.exe小技巧.txt
- [20180403]windows7小技巧.txtWindows
- VIM操作技巧
- [20230121]windows cmd.exe小技巧.txtWindows
- [20220316]完善vim gdb.vim外掛.txt
- [20191130]vim modeline.txt
- [20200424]vim visSum.vim合計外掛.txt
- [20180924]vim set wildmenu.txt
- [20230224]改動資料檔案小技巧.txt
- [20230508]能否一行完成(使用tee小技巧).txt
- vim基本配置與使用技巧
- [20231226]vim Align外掛使用例子.txt
- [20190909]完善vim的bccacl外掛.txt
- [20210507]完善vim bccalc_win外掛.txt
- [20200107]vim的特殊功能g命令.txt
- [20210810]完善vim bccalc_win外掛.txt
- [20210812]完善vim bccalc_linux外掛.txtLinux
- 『學了就忘』vim編輯器基礎 — 97、vim使用技巧
- vim技巧--提取文字與文字替換
- [20191202]od使用技巧.txt
- [20190913]完善vim的bccacl外掛2.txt
- [20191031]完善vim的bccalc外掛7.txt
- [20191101]完善vim的bccalc外掛8.txt
- [20220117]呼叫bccalc_win.vim外掛失效.txt
- [20201202]vim開啟多個TAB檔案.txt
- VIM 搜尋命令使用方法和技巧
- [20221104]bash exec使用技巧.txt
- 小技巧
- [20211224]vim外掛格式化sql語句.txtSQL
- [20200107]vim 按鍵與金山詞霸衝突.txt
- [20211231]vim自動格式化sql語句.txtSQL