Vim优化

时间:2024-06-25 12:03:08

升级python
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -xvf Python-3.6.5.tgz
cd Python-3.6.5
./configure --enable-shared \
--prefix=/usr/local/python3.6.5
make
make install
修改系统的默认python版本
ln -fs /usr/local/python3.6.5/bin/python3 /usr/bin/python
ln -fs /usr/local/python3.6.5/lib/libpython3.6m.so.1.0 /usr/lib64/libpython3.6m.so.1.0
修改yum配置文件(否则yum无法正常运行)/usr/bin/yum,改为原来系统默认的版本
将第一行的#!/usr/bin/python修改为系统原有的python版本地址#!/usr/bin/python2.6

升级vim
yum -y remove vim
yum install ncurses-devel
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp \
--enable-pythoninterp \
--with-python-config-dir=/usr/local/python3.6.5/lib/python3.6/config-3.6m-x86_64-linux-gnu \
--enable-python3interp=yes \
--enable-perlinterp \
--enable-luainterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make
make install

安装vim插件:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

编辑配置文件 ~/.vimrc

set nocompatible "Use Vim settings, rather than Vi settings
"Be IMproved filetype off "required! " I use Vundle https://github.com/gmarik/Vundle.vim as my
" preferred plugin manager.... never got the hang of
" vim-pathogen (no offence to the pathogen community) set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin() " Let vundle manage itself
Plugin 'gmarik/Vundle.vim' " Plugins
Plugin 'Valloric/YouCompleteMe'
Plugin 'nvie/vim-flake8'
Plugin 'itchyny/lightline.vim'
Plugin 'altercation/vim-colors-solarized' call vundle#end() " required
filetype plugin indent on "required! set backspace=indent,eol,start "allow backspacing over everything in insert mode set history=50 "keep 50 lines of command line history set ruler "show the cursor position all the time set showcmd "display incomplete commands set incsearch "do incremental searching set nu "show line numbers set expandtab "use spaces instead of tabs set tabstop=4 "insert 4 spaces whenever the tab key is pressed set shiftwidth=4 "set indentation to 4 spaces set hlsearch "highlight search terms set ic "Ignore Case during searches set autoindent "start new line at the same indentation level syntax enable "syntax highlighting set cmdheight=1 "The commandbar height set showmatch "Show matching bracets when text indicator is over them set nobackup " do not keep backup files, it's 70's style cluttering set noswapfile " do not write annoying intermediate swap files,
" who did ever restore from swap files
" anyway?
" https://github.com/nvie/vimrc/blob/master/vimrc#L141 set ttimeoutlen=50 "Solves: there is a pause when leaving insert mode set splitbelow " Horizontal splits open below current file set splitright " Vertical splits open to the right of the current file set wildmode=longest,list " Pressing <Tab> shows command suggestions similar to pressing <Tab>
" in bash set laststatus=2 " Solves lightline not showing " Mappings to traverse buffer list
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR> "Easy expansion of the active file directory
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' "Shortcut to Mute Highlighting
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l> "Root permission on a file inside VIM
cmap w!! w !sudo tee >/dev/null % "To use the Solarized Dark Theme
syntax enable
set background=dark
let g:solarized_termcolors=256
colorscheme darkblue

打开vim安装插件: :PluginInstall