您的位置:首页 > 其它

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

2012-12-27 21:00 465 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐