1、无插件vim使用php
一、查看修改代码python
1)光标移动git
h j k l 前下上后github
w b 词首、词尾vim
^ $ 句首、句尾curl
2)编辑url
x d r y p spa
a i o插件
. 重复以前的操做orm
:s/xxx/g 全局替换
3)搜索
:xxx 跳转到xxx行
/xxx 全局搜素xxx
* 全局匹配当前词
二、写代码
Ctrl+n 补全
2、vim配置:
配置文件:~/.vimrc
基本配置:
"set file type
filetype on
filetype plugin on
filetype indent on
" Tabstops are 4 spaces
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
"syntax highlight
syntax on
"show line number
set nu
插件配置:
1、安装pathogen.vim管理vim插件
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
在.vimrc中添加
execute pathogen#infect()
安装插件方法:
cd ~/.vim/bundle/
git clone https://github.com/dyng/ctrlsf.vim.git
2、安装配色方案
素雅 solarized(https://github.com/altercation/vim-colors-solarized )
多彩 molokai(https://github.com/tomasr/molokai )
复古 phd(http://www.vim.org/scripts/script.php?script_id=3139 )
前面说过,pathogen 没法安装主题插件,请将主题插件(仅 *.vim 文件而非插件目录,即,solarized.vim、molokai.vim、phd.vim)拷贝至 ~/.vim/colors/,而后在 .vimrc 中设定选用其做为主题:
" 配色方案
set background=dark
colorscheme solarized
"colorscheme molokai
"colorscheme phd
3. 文件浏览
NERDtree
https://github.com/scrooloose/nerdtree
.vimrc中添加:
" 使用 NERDTree 插件查看工程文件
nmap <Leader>fl :NERDTreeToggle<CR>
" 设置NERDTree子窗口宽度
let NERDTreeWinSize=32
" 设置NERDTree子窗口位置
let NERDTreeWinPos="left"
" 显示隐藏文件
let NERDTreeShowHidden=1
" NERDTree 子窗口中不显示冗余帮助信息
let NERDTreeMinimalUI=1
" 删除文件时自动删除文件对应 buffer
let NERDTreeAutoDeleteBuffer=1
4. 标签列表
tarbar
(须要先安装ctags)
https://github.com/majutsushi/tagbar
.vimrc中添加:
" 设置 tagbar 子窗口的位置出如今主编辑区的左边
let tagbar_left=1
" 设置显示/隐藏标签列表子窗口的快捷键。速记:tag list
nnoremap <Leader>tl :TagbarToggle<CR>
nmap <F8> :TagbarToggle<CR>
" 设置标签子窗口的宽度
let tagbar_width=32
" tagbar 子窗口中不显示冗余帮助信息
let g:tagbar_compact=1
5、python代码检查
flake-8.vim
http://www.vim.org/scripts/script.php?script_id=4440
六、自动pep8
autopep8
https://github.com/hhatto/autopep8#installation
.vimrc添加:
"#set autopep8
map <F6> :call FormartSrc()<CR>
func FormartSrc()
exec "w"
if &filetype == 'py'||&filetype == 'python'
exec "r !autopep8 -i --aggressive %"
endif
exec "e! %"
endfunc