Ubuntu下vim方向鍵不管用的問題
裝上ubuntu之後發現vi中方向鍵輸入的時候出現字母.
在$HOME/wyc/.vimrc這個檔案中(沒有就建立一個),要添加這樣一句
set nocompatible
2. 添加 backspace=2
最好的處理方法是:
可以在終端輸入
sudo apt-get install vim
安裝vim
cd /etc/vim
vim vimrc
大致如下:
” All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
” /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
” you can find below. If you wish to change any of those settings, you should
” do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
” everytime an upgrade of the vim packages is performed. It is recommended to
” make changes after sourcing debian.vim since it alters the value of the
” ‘compatible’ option.
” This line should not be removed as it ensures that various options are
” properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
” Uncomment the next line to make Vim more Vi-compatible
” NOTE: debian.vim sets ‘nocompatible’. Setting ‘compatible’ changes numerous
” options, so any other options should be set AFTER setting ‘compatible’.
“set compatible
” Vim5 and later versions support syntax highlighting. Uncommenting the next
” line enables syntax highlighting by default.
“syntax on
” If using a dark background within the editing area and syntax highlighting
” turn on this option as well
“set background=dark
” Uncomment the following to have Vim jump to the last position when
” reopening a file
“if has(“autocmd”)
” au BufReadPost * if line(“‘\”") > 0 && line(“‘\”") <= line(“$”)
“ \| exe “normal g’\”" | endif
“endif
” Uncomment the following to have Vim load indentation rules according to the
” detected filetype. Per default Debian Vim only load filetype specific
” plugins.
“if has(“autocmd”)
” filetype indent on
“endif
” The following are commented out as they cause vim to behave a lot
” differently from regular Vi. They are highly recommended though.
“set showcmd ” Show (partial) command in status line.
“set showmatch ” Show matching brackets.
“set ignorecase ” Do case insensitive matching
“set smartcase ” Do smart case matching
“set incsearch ” Incremental search
“set autowrite ” Automatically save before commands like :next and :make
“set hidden ” Hide buffers when they are abandoned
“set mouse=a ” Enable mouse usage (all modes) in terminals
” Source a global configuration file if available
” XXX Deprecated, please move your changes here in /etc/vim/vimrc
if filereadable(“/etc/vim/vimrc.local”)
source /etc/vim/vimrc.local
endif
“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”
“”Custom vim setting”"以下為自己添加的一些簡單設定
“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”
“有兩個的只能取其一
set ai/noai ” 自動縮排,新行與前面的行保持—致的自動空格/不自動空格(預設)
set aw/noaw ” 自動寫,轉入shell或使用:n編輯其他檔案時,當前的緩衝區被寫入/不寫
set flash/noflash ” 在出錯處閃爍但不嗚叫(預設)/使用嗚叫而不閃爍
set ic/noic ” 在查詢及模式比對時忽賂大小寫/不忽略大小寫(預設)
set nu/nonu
set number/nonumber ” 螢幕左邊顯示行號/不顯示行號(預設)
set showmatch ” 顯示括弧配對,當鍵入“]”“)”時,高亮度顯示匹配的括弧/預設不高亮
set showmode ” 處於文本輸入方式時加亮按鈕條中的模式指標/預設不指示當前模式
set showcmd ” 在狀態列顯示目前所執行的指令,未完成的指令片段亦會顯示出來
set warn/nowarn ” 對文本進行了新的修改後,離開shell時系統給出顯示(預設)
set ws/nows ” 在搜尋時如到達檔案尾則繞迴文件頭繼續搜尋
set wrap/nowrap ” 長行顯示自動折行
colorscheme evening ” 設定背景為夜間模式
filetype plugin on ” 自動識別檔案類型,自動匹配對應的, “檔案類型Plugin.vim”檔案,使用縮排定義檔案
set autoindent ” 設定自動縮排:即每行的縮排值與上一行相等;使用 noautoindent 取消設定
set cindent ” 以C/C++的模式縮排
set noignorecase ” 預設區分大小寫
set ruler ” 開啟狀態列尺規
set scrolloff=5 ” 設定游標離視窗上下邊界 5 行時視窗自動滾動
set shiftwidth=4 ” 設定 << 和 >> 命令移動時的寬度為 4
set softtabstop=4 ” 使得按退格鍵時可以一次刪掉 4 個空格,不足 4 個時刪掉所有剩下的空格)
set tabstop=4 ” 設定 tab 長度為 4
set wrap ” 自動換行顯示
syntax enable
syntax on ” 自動文法高亮