2016-08-17 53 views
5

這是我第一次注意到選擇模式在vim時,我不小心從visual-line模式由<c-g>觸發它。vim中「選擇模式」的常見用例是什麼?

Vim已經有visual mode供選擇文字什麼是selection mode的用例,誰能給我一個提示呢?

(注:我已經檢查了其描述爲

MS Windows文本選擇的相似手冊頁

,但我還是不太明白,爲什麼我們需要任何鼠標操作在vim中)

回答

5

選擇模式通常用於片段插件,例如vim-snipmate。可以創建對選擇模式唯一的映射,以免干擾常規的視覺模式行爲。

這裏是由德魯·尼爾Practical Vim的摘錄:

如果你很高興接受的Vim的模態性質,那麼你應該 找到選擇模式,其中包含用戶的手沒有多大用處誰 想讓Vim更像其他文本編輯器。我只能想到 只有一個地方我一直使用選擇模式:當使用模擬TextMate的片段功能的 插件時,選擇模式 突出顯示了活動佔位符。

+1

真的很感謝! 「很高興聽到」答案。 – Xlee

6

正如文檔所述,select modevisual mode有點不同。以下是您可以在其中執行的命令:

Commands in Select mode: 
- Printable characters, <NL> and <CR> cause the selection to be deleted, and 
    Vim enters Insert mode. The typed character is inserted. 
- Non-printable movement commands, with the Shift key pressed, extend the 
    selection. 'keymodel' must include "startsel". 
- Non-printable movement commands, with the Shift key NOT pressed, stop Select 
    mode. 'keymodel' must include "stopsel". 
- ESC stops Select mode. 

- CTRL-O switches to Visual mode for the duration of one command. *v_CTRL-O* 
- CTRL-G switches to Visual mode. 

Otherwise, typed characters are handled as in Visual mode. 

When using an operator in Select mode, and the selection is linewise, the 
selected lines are operated upon, but like in characterwise selection. For 
example, when a whole line is deleted, it can later be pasted halfway a line. 

您可以看到文檔here

他們所說的什麼「類似於微軟Windows的選擇」可能是您可以用Shift+Arrows擴展選擇,同時又有輸入的任何可打印字符將取代選定的文本,輸入insert mode

另外,參見this question/answer at the vi.SE

+0

謝謝你的努力!我知道醫生總是要去的地方,有時候他們會被我的知識範圍高度概括以達到 – Xlee

+0

@xuanyulee您能標記答案中的一個被接受嗎? – rgoliveira

相關問題