今天跟大家分享一下我的vim配置,仅仅是个人习惯而已。如果有需要,可以将一下内容copy替换掉~/.vimrc的内容:
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set fileencodings=utf-8,latin1 endif set tags=./tags,../tags,../../tags,../../../tags,../../../../tags,../../../../../tags,../../../../../../tags,../../../../../../../tags,../../../../../../../../tags,../../../../../../../../../tags set nocompatible " Use Vim defaults (much better!) set bs=indent,eol,start " allow backspacing over everything in insert mode "set ai " always set autoindenting on "set backup " keep a backup file set viminfo='20,\"50 " read/write a .viminfo file, don't store more " than 50 lines of registers set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time " Only do this part when compiled with support for autocommands if has("autocmd") " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 autocmd FileType java set expandtab " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal! g'\"" | \ endif endif if has("cscope") && filereadable("/usr/bin/cscope") set csprg=/usr/bin/cscope set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif filetype plugin on set autoindent set smartindent set tabstop=4 set shiftwidth=4 set showmatch set vb t_vb= syntax on set ruler set incsearch if has("vms") set nobackup else set backup endif if &term=="xterm" set t_Co=8 set t_Sb=[4%dm set t_Sf=[3%dm endif
百度了一下方法,都是修改~/.vimrc文件,但是我已经在此文件中加入了对应的修改:
在~/.vimrc文件中确认加上了:
au BufReadPost * if line(”‘\”") > 0|if line(”‘\”") <= line(”$”)|exe(”norm ‘\”")|else|exe “norm $”|endif|endifset viminfo=’1000,f1,<500
后来才发现问题的根本所在:原来我们编辑vim文件的状态记录在~/.vimifo文件中,先执行一下
ls ~/.viminfo -l
会发现显示为:
-rw------- 1 root root 5304 2014-02-19 13:57 /home/topwise/.viminfo
发现了,只有root用户组才能修改此文件。只用改变一下该文件所属用户组即可,我这里是改成topwise用户组:
sudo chown topwise:topwise ~/.viminfo
修改之后,再去看看成果吧。是不是OK了?
如果还是不行,并且读写权限不是rw ,可以修改此文件的读写权限:
chmod 0600 ~/.viminfo