如果要使用IDE工具,要做的就是安装vim-nox.
但是安装的时候有可能会报这样的错误。
The following packages have unmet dependencies:
vim-nox : Depends: vim-common (= 2:7.3.547-7) but 2:7.4.488-7 is to be installed
Depends: libperl5.14 (>= 5.14.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
sudo apt-get remove vim-common
卸载完这个之后后面还会再报一个错误,这个时候就需要再卸载一次。
The following packages have unmet dependencies:
vim-nox : Depends: vim-common (= 2:7.4.1689-3ubuntu1) but 2:7.4.1689-3ubuntu1.2 is to be installed
Depends: vim-runtime (= 2:7.4.1689-3ubuntu1) but 2:7.4.1689-3ubuntu1.2 is to be installed
这个时候正常应该只有下面这个错误了。这个时候只需要再执行
sudo apt-get remove vim-runtime
sudo apt-get install vim-nox
Vundle 是 vim 的众多插件管理器之一,也算是使用最为广泛的一个。安装 Vundle:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
touch ~/.vimrc
"vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"git interface
Plugin 'tpope/vim-fugitive'
"filesystem
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
"html
" isnowfy only compatible with python not python3
Plugin 'isnowfy/python-vim-instant-markdown'
Plugin 'jtratner/vim-flavored-markdown'
Plugin 'suan/vim-instant-markdown'
Plugin 'nelstrom/vim-markdown-preview'
"python sytax checker
Plugin 'nvie/vim-flake8'
Plugin 'vim-scripts/Pydiction'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'scrooloose/syntastic'
"auto-completion stuff
"Plugin 'klen/python-mode'
Plugin 'Valloric/YouCompleteMe'
Plugin 'klen/rope-vim'
"Plugin 'davidhalter/jedi-vim'
Plugin 'ervandew/supertab'
""code folding
Plugin 'tmhedberg/SimpylFold'
"Colors!!!
Plugin 'altercation/vim-colors-solarized'
Plugin 'jnurmine/Zenburn'
call vundle#end()
filetype plugin indent on " enables filetype detection
let g:SimpylFold_docstring_preview = 1
"autocomplete
let g:ycm_autoclose_preview_window_after_completion=1
"custom keys
let mapleader=" "
map g :YcmCompleter GoToDefinitionElseDeclaration
"
call togglebg#map("")
"colorscheme zenburn
"set guifont=Monaco:h14
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
"I don't like swap files
set noswapfile
"turn on numbering
set nu
"python with virtualenv support
py << EOF
import os.path
import sys
import vim
if 'VIRTUA_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir,'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
"it would be nice to set tag files by the active virtualenv here
":set tags=~/mytags "tags for ctags and taglist
"omnicomplete
autocmd FileType python set omnifunc=pythoncomplete#Complete
"------------Start Python PEP 8 stuff----------------
" Number of spaces that a pre-existing tab is equal to.
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4
"spaces for indents
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
au BufRead,BufNewFile *.py set softtabstop=4
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
au BufRead,BufNewFile *.py,*.pyw, set textwidth=100
" Use UNIX (\n) line endings.
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
" Set the default file encoding to UTF-8:
set encoding=utf-8
" For full syntax highlighting:
let python_highlight_all=1
syntax on
" Keep indentation level from previous line:
autocmd FileType python set autoindent
" make backspaces more powerfull
set backspace=indent,eol,start
"Folding based on indentation:
autocmd FileType python set foldmethod=indent
"use space to open folds
nnoremap za
" ----------Stop python PEP 8 stuff--------------
"js stuff"
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2
© 2017 GitHub, Inc.
PluginInstall
杀手级插件。vim上的自动补全神器,能够提供类似IDE的自动补全体验,还能和Syntastic配合提供实时语法检查。YouCompleteMe与其他插件不同的地方在于不仅需要安装,还需要自己手动编译,而且还需要在.vimrc中配置。
YouCompleteMe支持的语言有:
C、Objectiv-c、C#、C++、Objectiv-C++、Php、Javascript、Typescript、python、Go、Rust
安装只需要一条命令:
Plugin ‘Valloric/YouCompleteMe’
编译的命令:
cd ~/.vim/bundle/YouCompleteMe
./install.py –clang-completer
参数 –clang-completer是为了加上C系列语言的自动补全,如果不需要可以不加,它同时还支持其他语言的补全,详细请看官方文档。
YouCompleteMe涉及到的配置选项有很多,笔者也没有完全了解,此外,个人觉得Syntactic的提示略丑陋,因此没有安装。此处指列出笔者在使用的,详细请查看官方文档:
"默认配置文件路径"
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
"打开vim时不再询问是否加载ycm_extra_conf.py配置"
let g:ycm_confirm_extra_conf=0
set completeopt=longest,menu
"python解释器路径"
let g:ycm_path_to_python_interpreter='/usr/local/bin/python'
"是否开启语义补全"
let g:ycm_seed_identifiers_with_syntax=1
"是否在注释中也开启补全"
let g:ycm_complete_in_comments=1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
"开始补全的字符数"
let g:ycm_min_num_of_chars_for_completion=2
"补全后自动关机预览窗口"
let g:ycm_autoclose_preview_window_after_completion=1
" 禁止缓存匹配项,每次都重新生成匹配项"
let g:ycm_cache_omnifunc=0
"字符串中也开启补全"
let g:ycm_complete_in_strings = 1
"离开插入模式后自动关闭预览窗口"
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"回车即选中当前项"
inoremap pumvisible() ? '' : '\'
"上下左右键行为"
inoremap pumvisible() ? '\' : '\'
inoremap pumvisible() ? '\' : '\'
inoremap pumvisible() ? '\\\' : '\'
inoremap pumvisible() ? '\\\' : '\'
用于美化状态栏,原生的状态栏略丑而且显示的信息很少,因此这款好看又实用的状态栏就派上用场啦。开箱即用,方便快捷。
在YouCompleteMe配置的时候,我依然遇到的一些错误还没有解决。上面的代码最好分批一点一点拷贝,执行PluginInstall。这样便于验证,找到错误原因。
如果还是没有弄好,就直接在pycharm里面使用插件吧。
下载安装IdeaVim插件
在Pycharm的主工具栏中单击设置按钮,在IDE Settings界面下选择 Plugins页面。此时将会显示当前平台下安装的所有插件。然而IdeaVim并不在其中,此时需要单击Browse JetBrains plugins按钮,在搜索栏中键入vim来找到对应的插件,然后下载安装,重启之后就可以使用了。
http://www.jianshu.com/p/f0513d18742a
https://segmentfault.com/a/1190000003962806
http://learnvimscriptthehardway.stevelosh.com/
http://blog.csdn.net/github_33934628/article/details/51854843