亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在連續的行中為我的vi編輯器添加前綴?

如何在連續的行中為我的vi編輯器添加前綴?

HUH函數 2021-04-12 17:19:03
我的輸入:Test1.txt aabbcc預期結果應為chown用戶:user achmod 755 achown用戶:user bchmod 755 bchown用戶:user cchmod 755 c請提出在單個文檔中處理10k條以上行的最佳方法?;旧蠟橥宦窂教砑?個不同的前綴命令(一次又一次重復兩次)
查看完整描述

2 回答

?
千萬里不及你

TA貢獻1784條經驗 獲得超9個贊

使用唯一路徑列表更容易,因此請從刪除其他所有行開始:


:g/^/+d

(摘自此答案)


然后,將每一行替換為所需的命令:


:%s/.*/chown user:user &\rchmod 755 &/


:%                                     run this command on the entire buffer:

  s                                    replace

   /.*/                                an entire line with

       chown user:user                 (literal "chown user:user ")

                       &               the entirety of the match

                        \r             newline

                          chmod 755    (literal "chmod 755 ")

                                    &  the entirety of the match again

                                     / (end the regex)

(&并\r記錄在中:help sub-replace-special。)


查看完整回答
反對 回復 2021-04-16
  • 2 回答
  • 0 關注
  • 411 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號