参考视频:
好的,在我们默认的centos6的操作系统中使用的python2,我们一般会再去安装一个python3。我的环境就是python 和python3都有,python -V就是python2.6的版本。
我们需要下载vim进行重新编译安装,我们可以从官网下载源码包。这里就是我下载的vim包:
在编译安装之前,我们还需要安装python-devel的包,这个yum install python-devel就行了。 还有安装git。
执行rpm -ql python-devel会看到devel生成了一个配置文件目录:
准备完成之后了,我们如果原来有装vim的话,可以将其卸载, 好的,我们开始编译安装vim:
1、cd /vim74b/src
2、./configure --enable-pythoninterp --enable-python3interp --with-python-config-dir=/usr/lib64/python2.6/config/ --with-features=huge --prefix=$HOME/opt/vim
执行过程中,我们可以看到这么一段:
另一台机器:
3、make $$ make install
然后就是将vim加入PATH。这个大家应该都会。
然后执行 vim --version ,可以看到vim 的一些信息:
现在开始配置 .vimrc文件,vim ~/.vimrc , 这里我们也可以一步一步的参考视频里的操作做,但是要非常认真的去看,这个文件可以参考下面模板,:
set guifont=courier_new:h18set cursorline culset encoding=utf-8colorscheme darkbluenmap gO Ojnmap g o k" source $MYVIMRC reloads the saved $MYVIMRCnmap s :source $MYVIMRC" opens $MYVIMRC for editing, or use :tabedit $MYVIMRCnmap v :e $MYVIMRC" is \ by default, so those commands can be invoked by doing \v and \s" Sample .vimrc file by Martin Brochhaus" Presented at PyCon APAC 2012" Installed Plug-Ins:" Pathogen" vim powerline" nerdtree" jedi-vim" ctrlp" Automatic reloading of .vimrcautocmd! bufwritepost .vimrc source %" Better copy & paste" When you want to paste large blocks of code into vim, press F2 before you" paste. At the bottom you should see ``-- INSERT (paste) --``.set pastetoggle= set clipboard=unnamed" Mouse and backspaceset mouse=a " on OSX press ALT and clickset bs=2 " make backspace behave like normal again" Rebind key" I like to have it here becuase it is easier to reach than the default and" it is next to ``m`` and ``n`` which I use for navigating between tabs.let mapleader = ","" Bind nohl" Removes highlight of your last search" `` `` stands for ``CTRL`` and therefore `` `` stands for ``CTRL+n``"noremap :nohl "vnoremap :nohl "inoremap :nohl " Quicksave command""noremap :update ""vnoremap :update ""inoremap :update " Quick quit commandnoremap e :quit " Quit current windownoremap E :qa! " Quit all windows" bind Ctrl+ keys to move around the windows, instead of using Ctrl+w + " Every unnecessary keystroke that can be saved is good for your health :)map jmap kmap lmap h" easier moving between tabsmap n :tabprevious map m :tabnext " map sort function to a keyvnoremap s :sort " easier moving of code blocks" Try to go into visual mode (v), thenselect several lines of code here and" then press ``>`` several times.vnoremap < >gv " better indentation" Show whitespace" MUST be inserted BEFORE the colorscheme commandautocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=redau InsertLeave * match ExtraWhitespace /\s\+$/" Color scheme" mkdir -p ~/.vim/colors && cd ~/.vim/colors" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400set t_Co=256color wombat256mod" Enable syntax highlighting" You need to reload this file for the change to applyfiletype offfiletype plugin indent onsyntax on" Showing line numbers and lengthset number " show line numbersset tw=79 " width of document (used by gd)set nowrap " don't automatically wrap on loadset fo-=t " don't automatically wrap text when typingset colorcolumn=80highlight ColorColumn ctermbg=233" easier formatting of paragraphsvmap Q gqnmap Q gqap" Useful settingsset history=700set undolevels=700" Real programmers don't use TABs but spacesset tabstop=4set softtabstop=4set shiftwidth=4set shiftroundset expandtab" Make search case insensitiveset hlsearchset incsearchset ignorecaseset smartcase" Disable stupid backup and swap files - they trigger too many events" for file system watchersset nobackupset nowritebackupset noswapfile" Setup Pathogen to manage your plugins" mkdir -p ~/.vim/autoload ~/.vim/bundle" curl -so ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim"Now you can install any plugin into a .vim/bundle/plugin-name/ foldercall pathogen#infect()" ============================================================================" Python IDE Setup" ============================================================================" Settings for vim-powerline" cd ~/.vim/bundle" git clone git://github.com/Lokaltog/vim-powerline.gitset laststatus=2" Settings for ctrlp" cd ~/.vim/bundle" git clone https://github.com/kien/ctrlp.vim.gitlet g:ctrlp_max_height = 30set wildignore+=*.pycset wildignore+=*_build/*set wildignore+=*/coverage/*" Settings for python-mode" Note: I'm no longer using this. Leave this commented out" and uncomment the part about jedi-vim instead" cd ~/.vim/bundle" git clone https://github.com/klen/python-mode""map g :call RopeGotoDefinition() ""let ropevim_enable_shortcuts = 1""let ropevim_enable_shortcutsg:pymode_rope_goto_def_newwin = "vnew"""let g:pymode_rope_extended_complete = 1""let g:pymode_breakpoint = 0""let g:pymode_syntax = 1""let g:pymode_syntax_builtin_objs = 0""let g:pymode_syntax_builtin_funcs = 0""map b Oimport ipdb; ipdb.set_trace() # BREAKPOINT " Settings for jedi-vim" " cd ~/vimfiles/bundle" " git clone git://github.com/davidhalter/jedi-vim.gitlet g:jedi#usages_command = " z"let g:jedi#popup_on_dot = 1let g:jedi#popup_select_first = 0let g:jedi#show_call_signatures = 1let g:jedi#force_py_version = 2call jedi#configure_call_signatures()map b Oimport ipdb; ipdb.set_trace() # BREAKPOINT " Better navigating through omnicomplete option list" See http://stackoverflow.com/questions/2170023/how-to-map-keys-for-popup-menu-in-vim set completeopt=longest,menuone function! OmniPopup(action) if pumvisible() if a:action == 'j' return "\ " elseif a:action == 'k' return "\ " endif endif return a:action endfunction"" inoremap =OmniPopup('j') "" inoremap =OmniPopup('k') " Python folding" mkdir -p ~/.vim/ftplugin" wget -O ~/.vim/ftplugin/python_editing.vim http://www.vim.org/scripts/download_script.php?src_id=5492 set nofoldenable"" nerdtree" " cd ~/vimfiles/bundle""git clone https://github.com/scrooloose/nerdtree.gitmap :NERDTreeToggle let g:NERDTreeDirArrows=1let NERDTreeWinPos ="left"let NERDTreeIgnore = ['\.pyc$']let g:NERDTreeDirArrowExpandable = '▸'let g:NERDTreeDirArrowCollapsible = '▾'""let NERDTreeShowBookmarks=1" NERDTress File highlightingfunction! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg) exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'endfunctioncall NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
使用了模板前,还需要下载颜色包文件。
mkdir -p ~/.vim/colors
cd ~/.vim/colors/
wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
再下载:
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -so ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim
再下载:
" cd ~/.vim/bundle
" git clone git://github.com/Lokaltog/vim-powerline.git
再下载:
" cd ~/.vim/bundle
" git clone https://github.com/kien/ctrlp.vim.git
再下载:
" cd ~/.vim/bundle
" git clone git://github.com/davidhalter/jedi-vim.git
再下载:
" mkdir -p ~/.vim/ftplugin
" wget -O ~/.vim/ftplugin/python_editing.vim http://www.vim.org/scripts/download_script.php?src_id=5492
参考:
可能还需要pip2 install jedi 和pip3 install jedi