2013-10-12 72 views
2

我是一個新的vim用戶。在問這個問題之前,我已經經歷了一些在SO上提出的類似問題,例如: Q-1,Q-2,Q-3Q-4。他們都沒有解決我看似簡單的問題。如果有人能幫助我理解我在這裏失去的東西,那將是非常棒的。〜/ .vimrc中的更新沒有被反映

問題描述:我正在使用Ubuntu-12.04 32位系統。無論我在~/.vimrc文件中更改了什麼,它都不會反映在vim如何顯示我的文件。最近,我添加了幾行將vim的狀態行更改爲更多信息和顏色編碼(從here複製)。即使在使用:so ~/.vimrc採購~/.vimrc後,也沒有實現預期的更改,並且狀態行與默認值保持相同。以下給出的是我的~/.vimrc文件。

請幫我理解我錯過了什麼? Statusline添加的行數爲~/.vimrc文件的末尾。

感謝

~/.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 
" following enables syntax highlighting by default. 
if has("syntax") 
    syntax on 
endif 

" 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("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 
"endif 

" Uncomment the following to have Vim load indentation rules and plugins 
" according to the detected filetype. 
"if has("autocmd") 
" filetype plugin 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) 

" Source a global configuration file if available 
if filereadable("/etc/vim/vimrc.local") 
    source /etc/vim/vimrc.local 
endif 

map <F3> gT 
map <F4> gt 

syntax enable 
syntax on 
colorscheme darkblue 
"set autoindent 
set cindent 
set nu 
set nowrap 
set softtabstop=2 
set shiftwidth=2 
"set expandtab 
autocmd BufWinLeave .* mkview 
autocmd BufWinEnter .* silent loadview 
"set textwidth=60 

"Lines added to change status line 
"define 3 custom highlight groups 
hi User1 ctermbg=green ctermfg=red guibg=green guifg=red 
hi User2 ctermbg=red ctermfg=blue guibg=red guifg=blue 
hi User3 ctermbg=blue ctermfg=green guibg=blue guifg=green 

set statusline= 
set statusline+=%1* "switch to User1 highlight 
set statusline+=%F "full filename 
set statusline+=%2* "switch to User2 highlight 
set statusline+=%y "filetype 
set statusline+=%3* "switch to User3 highlight 
set statusline+=%l "line number 
set statusline+=%* "switch back to statusline highlight 
set statusline+=%P "percentage thru file 
+1

@JoachimIsaksson謝謝!它工作... – Abhinav

+0

這是在vim的運行時發現的默認vimrc的副本。您應該刪除第一行到'map gT'(不包括)的所有內容。 – romainl

回答

1

要在任何時候的狀態行可見,只需添加set laststatus=2.vimrc

的標準值是laststatus=1,這隻能說明狀態行,如果有至少兩個可見窗口(據我所知,只有當你分裂兩個緩衝區之間的屏幕)