2012-01-17 1388 views
12

在視覺模式下使用Vim時,選擇文本然後調用一個冒號命令會顯示: '<,'>而不僅僅是:,因爲它會在我執行其他操作(例如打開文件)時顯示。使用vim,什麼是「'<,'>」?

'<,'>是什麼意思?

使用linux (debian)gnome-terminalvim7.2

回答

26

這意味着,你:'<,'>後鍵入以下命令將在您所選擇的文件的一部分工作。

例如,:'<,'>d會刪除選定的塊,而:d將刪除光標下的行。

類似地,:'<,'>w fragment.txt會將所選塊寫入名爲fragment.txt的文件。

兩個逗號分隔的事物('<'>)是與選定區域的開始和結束對應的標記。從幫助頁面(:help '<):當以這種方式使用

             *'<* *`<* 
'< `<     To the first line or character of the last selected 
         Visual area in the current buffer. For block mode it 
         may also be the last character in the first line (to 
         be able to define the block). {not in Vi}. 

                 *'>* *`>* 
'> `>     To the last line or character of the last selected 
         Visual area in the current buffer. For block mode it 
         may also be the first character of the last line (to 
         be able to define the block). Note that 'selection' 
         applies, the position may be just after the Visual 
         area. {not in Vi}. 

,標記只需指定下面的命令的範圍(見:help range)。當然,它們可以與其他行號說明符混合並匹配。例如,下面的命令刪除從選定區域的開始的所有行的文件的末尾:

:'<,$d

Vim的維基上的Vim範圍more information

+1

更多見解':help range'。 – Benoit 2012-01-17 16:49:54

相關問題