Linux 下的幾個常用操作

來源:互聯網
上載者:User
尋找



1) 字串尋找

grep -r  xxx   ./             在目前的目錄中尋找xxx字元

 

2) 檔案尋找
find path -name  file   在path路徑下尋找file檔案

 

製作補丁檔案





diff -uNb  Oldfile  Newfile  > patchfile    產生補丁檔案patchfile

 

vim 操作






1) 尋找

/xxx        尋找xxx字串

 

2) 粘貼
p   在游標處粘貼

3) 撤銷
u  撤銷一次
nu 撤銷n次操作

4) 重做
CTL+r

5) 刪除
dd   刪除一行
ndd  刪除游標後的n行

6) 複製
yy   複製一行
nyy  複製游標後的n行

 

7) 尋找替換
:s/str1/str2     用字串 str2 替換行中首次出現的字串str1
:1,$ s/str1/str2 用字串 str2 替換本文中所有出現的字串str1

 

vim環境設定






1) 顯示行號
:set nu

2) 文法高亮顯示
:syntax on

3) 設定tab鍵空格數
:set shiftwidth=4

 

4) 顯示函數列表
:Tlist  顯示函數列表

5)設定滑鼠

:set mouse=a       滑鼠可用
:set mouse=        滑鼠不可用

 

6)跳轉快速鍵

ctrl+] 跳轉到定義的地方
ctrl+o 跳回上一級
ctrl+t 跳回上一級

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.