【vim】在vim中将unix命令执行的结果保存在vim文件中

来源:互联网 发布:今年淘宝总额 编辑:程序博客网 时间:2024/05/16 16:55

You can combine :read with a call to Unix, to read the results of a Unix command into

your file. As a very simple example:


示例1:
:r !date   (此命令是将当前日期添加到当前行)

示例2:

假设有如下文本,phone.log:

=======================

Willing, Sue 333-4444
Walsh, Linda 555-6666
Quercia, Valerie 777-8888
Dougherty, Nancy 999-0000

==========================

然后执行命令:

:r !sort phone.log

执行后,会将排过序的数据插入到当前行的下面


示例3:

Suppose you are editing a file and want to insert text from another file in the directory,
but you can’t remember the new file’s name. You could perform this task the long way:
exit your file, give the ls command, note the correct filename, reenter your file, and
search for your place.
Or you could do the task in fewer steps:
Keystrokes
:!ls
Results file1 newfile file2 practice  letter
Display a list of files in the current directory. Note the correct filename. Press ENTER to
continue editing.
:r newfile
"newfile" 35 lines, 949 characters
Read in the new file.


原创粉丝点击