Today, I will share with you my vim configuration, which is just a personal habit. If necessary, replace the following content copy ~ /. Vimrc content:
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set fileencodings=utf-8,latin1endifset tags=./tags,../tags,../../tags,../../../tags,../../../../tags,../../../../../tags,../../../../../../tags,../../../../../../../tags,../../../../../../../../tags,../../../../../../../../../tagsset 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 fileset viminfo='20,\"50" read/write a .viminfo file, don't store more" than 50 lines of registersset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the time" Only do this part when compiled with support for autocommandsif 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'\"" | \ endifendifif 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 csverbendif" 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 hlsearchendiffiletype plugin onset autoindentset smartindentset tabstop=4set shiftwidth=4set showmatchset vb t_vb=syntax onset rulerset incsearchif has("vms")set nobackupelseset backupendifif &term=="xterm" set t_Co=8 set t_Sb=[4%dm set t_Sf=[3%dmendif
In addition, I encountered a problem. After compiling a file with vim, I quit and enter the file. I found that I jumped to the file header again. This is not what I want. When I want to access this file, I will jump to the position I modified last time. What should we do?
Baidu used the following methods to modify them ~ /. Vimrc file, but I have added the corresponding modifications to this file:
In ~ /. Added the following to the vimrc file:
Au BufReadPost * if line ("'\" ")> 0 | if line ("' \ "") <= line ("$ ") | exe ("norm' \" ") | else | exe" norm $ "| endif | endifset viminfo = '2017, f1, <1000
The root cause of the problem was discovered later: We edited the vim file's status record in ~ /. Run the following command in the vimifo file:
Ls ~ /. Viminfo-l
It is displayed as follows:
-Rw ------- 1 root 5304/home/topwise/. viminfo
Only the root user group can modify the file. You only need to change the user group to which the file belongs. Here I will change it to the topwise user group:
Sudo chown topwise: topwise ~ /. Viminfo
After modification, let's see the results. OK?
If it still does not work and the read and write permissions are not rw, you can modify the read and write permissions of this file:
Chmod 0600 ~ /. Viminfo