vim中backspace失效解決辦法
現(xiàn)象
在mac中使用vim打開(kāi)文件后构回,在insert模式下使用backspace(delete)鍵只能編輯本次修改的內(nèi)容孝赫,無(wú)法編輯文件中之前的內(nèi)容贰您。
解決辦法
在~/.vimrc
中設(shè)置backspace
項(xiàng)的配置內(nèi)容為2。
即在~/.vimrc
中加入一條配置
set backspace=2
分析原因
vim官方文檔對(duì)于backspace
的解釋如下:
'backspace' 'bs' string (default "")
global
{not in Vi}
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert mode. This is a list of items, separated by commas. Each item allows a way to backspace over something:
--------------------------------------------------------------
value | effect
indent | allow backspacing over autoindent
eol | allow backspacing over line breaks (join lines)
start | allow backspacing over the start of insert; CTRL-W and CTRL-U stop once at the start of insert.
---------------------------------------------------------------
When the value is empty, Vi compatible backspacing is used. For backwards compatibility with version 5.4 and earlier:
---------------------------------------------------
value | effect
0 | same as ":set backspace=" (Vi compatible)
1 | same as ":set backspace=indent,eol"
2 | same as ":set backspace=indent,eol,start"
---------------------------------------------------
See |:fixdel| if your <BS> or <Del> key does not do what you want. NOTE: This option is set to "" when 'compatible' is set.
根據(jù)文檔中的內(nèi)容可知焊刹,有三種值可以被設(shè)置矗钟,indent
縮進(jìn),eol
行尾筑凫,start
剛開(kāi)始插入滑沧。
默認(rèn)的vim的設(shè)置是設(shè)置為0,為了兼容vi的使用方法巍实。(雖然在mac系統(tǒng)中vi命令只是vim的一個(gè)符號(hào)鏈接滓技。)
因此,我們將backspace
的配置設(shè)置成2棚潦,即可使用backspace
在insert
模式下進(jìn)行編輯令漂。