├── .gitignore ├── .gitmodules ├── .vimrc ├── Readme.md ├── screenshots ├── vim-1.png ├── vim-2.png ├── vim-3.png └── vim-5.png └── undo_dirs └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | undo_dirs/* 2 | 3 | plugins/goyo.vim/doc 4 | plugins/ag.vim/.netrwhist 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "plugins/vim-pathogen"] 2 | path = plugins/vim-pathogen 3 | url = git@github.com:tpope/vim-pathogen.git 4 | [submodule "plugins/nerdtree"] 5 | path = plugins/nerdtree 6 | url = git@github.com:scrooloose/nerdtree.git 7 | [submodule "plugins/ag.vim"] 8 | path = plugins/ag.vim 9 | url = git@github.com:rking/ag.vim.git 10 | [submodule "plugins/ctrlp.vim"] 11 | path = plugins/ctrlp.vim 12 | url = git@github.com:ctrlpvim/ctrlp.vim.git 13 | [submodule "plugins/vim-commentary"] 14 | path = plugins/vim-commentary 15 | url = git@github.com:tpope/vim-commentary.git 16 | [submodule "plugins/vim-fugitive"] 17 | path = plugins/vim-fugitive 18 | url = git@github.com:tpope/vim-fugitive.git 19 | [submodule "plugins/vim-colors-solarized"] 20 | path = plugins/vim-colors-solarized 21 | url = git@github.com:altercation/vim-colors-solarized.git 22 | [submodule "plugins/vim-multiple-cursors"] 23 | path = plugins/vim-multiple-cursors 24 | url = git@github.com:terryma/vim-multiple-cursors.git 25 | [submodule "plugins/goyo.vim"] 26 | path = plugins/goyo.vim 27 | url = git@github.com:junegunn/goyo.vim.git 28 | [submodule "plugins/lightline.vim"] 29 | path = plugins/lightline.vim 30 | url = git@github.com:itchyny/lightline.vim.git 31 | [submodule "plugins/emmet-vim"] 32 | path = plugins/emmet-vim 33 | url = git@github.com:mattn/emmet-vim.git 34 | [submodule "plugins/vim-javascript"] 35 | path = plugins/vim-javascript 36 | url = git@github.com:pangloss/vim-javascript.git 37 | [submodule "plugins/vim-jsx"] 38 | path = plugins/vim-jsx 39 | url = git@github.com:mxw/vim-jsx.git 40 | [submodule "plugins/delimitMate"] 41 | path = plugins/delimitMate 42 | url = git@github.com:Raimondi/delimitMate.git 43 | [submodule "plugins/vim-markdown"] 44 | path = plugins/vim-markdown 45 | url = git@github.com:plasticboy/vim-markdown.git 46 | [submodule "plugins/vim-pug"] 47 | path = plugins/vim-pug 48 | url = git@github.com:digitaltoad/vim-pug.git 49 | [submodule "plugins/vim-json"] 50 | path = plugins/vim-json 51 | url = git@github.com:elzr/vim-json.git 52 | [submodule "plugins/vim-syntastic"] 53 | path = plugins/vim-syntastic 54 | url = git@github.com:vim-syntastic/syntastic.git 55 | [submodule "plugins/vim-jsdoc"] 56 | path = plugins/vim-jsdoc 57 | url = git@github.com:heavenshell/vim-jsdoc.git 58 | [submodule "plugins/typescript-vim"] 59 | path = plugins/typescript-vim 60 | url = git@github.com:leafgarland/typescript-vim.git 61 | [submodule "plugins/vim-go"] 62 | path = plugins/vim-go 63 | url = git@github.com:fatih/vim-go.git 64 | [submodule "plugins/vim-vue"] 65 | path = plugins/vim-vue 66 | url = https://github.com/posva/vim-vue.git 67 | [submodule "plugins/dart-vim-plugin"] 68 | path = plugins/dart-vim-plugin 69 | url = https://github.com/dart-lang/dart-vim-plugin 70 | [submodule "plugins/wakatime"] 71 | path = plugins/wakatime 72 | url = git://github.com/wakatime/vim-wakatime.git 73 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | " 开启缩进 2 | filetype plugin indent on 3 | 4 | let mapleader="," 5 | 6 | " ,w -> 保存 7 | nmap w :w! 8 | " W -> 使用密码保存只读文件 9 | command W w !sudo tee % > /dev/null 10 | 11 | 12 | " 鼠标最下位置控制在倒数第七行 13 | set scrolloff=7 14 | set wildmenu 15 | set cmdheight=2 16 | 17 | " 智能处理退格键的功能 18 | set backspace=eol,start,indent 19 | 20 | " 忽略大小写 21 | set ignorecase 22 | set smartcase 23 | 24 | " 高亮查找关键字 25 | set hlsearch 26 | 27 | " 查找关键字时,即时匹配 28 | set incsearch 29 | 30 | set magic 31 | set showmatch 32 | set mat=2 33 | 34 | set foldcolumn=1 35 | 36 | 37 | syntax enable 38 | set encoding=utf8 39 | 40 | " 不自动备份文件 41 | set nobackup 42 | set nowritebackup 43 | 44 | " 不产生交换文件(当打开一个文件未正常关闭时会产生交换文件) 45 | set noswapfile 46 | 47 | " 兼容 tmux (若不设置此项,tmux 仅仅会在内容区设置背景) 48 | set term=screen-256color 49 | set background=dark 50 | 51 | " tab == 2 space 52 | set expandtab 53 | set smarttab 54 | set shiftwidth=2 55 | set tabstop=2 56 | 57 | " autocmd FileType markdown set shiftwidth=4 tabstop=4 58 | 59 | set autoindent 60 | set smartindent 61 | set autoread 62 | au CursorHold,CursorHoldI * checktime 63 | 64 | " 自动换行 65 | set wrap 66 | 67 | " 快速切换窗口 68 | map j 69 | map k 70 | map h 71 | map l 72 | 73 | set switchbuf=useopen,usetab,newtab 74 | set showtabline=2 75 | 76 | " Return to last edit position when opening files (You want this!) 77 | autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 78 | 79 | " 显示状态栏 80 | set laststatus=2 81 | 82 | " 缩进 83 | set foldmethod=syntax 84 | 85 | " 多文件操作时,保留操作记录(可以回退) 86 | set undofile 87 | set undodir=~/.vim-config/undo_dirs 88 | 89 | " 开启剪切板 90 | " set clipboard=unnamedplus 91 | 92 | 93 | 94 | " --------------------------- plugins -------------------------------- 95 | set rtp+=~/.vim-config/plugins/vim-pathogen 96 | 97 | call pathogen#infect('~/.vim-config/plugins/{}') 98 | call pathogen#helptags() 99 | 100 | " => Nerd Tree 101 | let g:NERDTreeWinPos = "right" 102 | let NERDTreeShowHidden=0 103 | let NERDTreeIgnore = ['\.pyc$', '__pycache__', 'node_modules'] 104 | let g:NERDTreeWinSize=35 105 | map nn :NERDTreeToggle 106 | map nb :NERDTreeFromBookmark 107 | map nf :NERDTreeFind 108 | 109 | " => CTRL-P 110 | let g:ctrlp_working_path_mode = 0 111 | 112 | map f :CtrlPMRUFiles 113 | map b :CtrlPBuffer 114 | 115 | let g:ctrlp_max_height = 15 116 | let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee' 117 | 118 | " => Syntastic 119 | " let g:syntastic_javascript_checkers = ['eslint'] 120 | " let g:syntastic_html_checkers = ['eslint'] 121 | let g:syntastic_always_populate_loc_list = 1 122 | 123 | " => Solarized Theme 124 | set background=light 125 | colorscheme solarized 126 | 127 | " => lightline 128 | let g:lightline = { 129 | \ 'colorscheme': 'solarized', 130 | \ } 131 | 132 | " => vim-jsx 133 | let g:jsx_ext_required = 0 134 | 135 | " => vim-emmet 136 | let g:user_emmet_settings = { 137 | \ 'javascript.jsx' : { 138 | \ 'extends' : 'jsx', 139 | \ }, 140 | \} 141 | 142 | " => vim-markdown 143 | let g:vim_markdown_new_list_item_indent = 4 144 | 145 | let dart_style_guide = 2 146 | let dart_format_on_save = 1 147 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Vim config for shanyue 2 | 3 | 配置使用 `pathogen` 和 `git submodules` 进行插件管理,使用本配置文件可以使您快速上手vim。本配置文件对于前端友好,前端开发者可以使用 `emmet` 可以快速编写html和css,另外有 `jsx` 与 `pug`语法高亮,并且可以使用 `eslint` 进行语法检查。本人早期使用 [amix/vimrc](https://github.com/amix/vimrc) 进行开发,深入浅出,帮助很大,非常推荐。 4 | 5 | 欢迎 star!欢迎 pr! 6 | 7 | ## 配置 8 | 9 | ``` 10 | $ git clone git@github.com:shfshanyue/vim-config.git ~/.vim-config --recursive 11 | $ cd ~/.vim-config 12 | $ ln -s $(pwd)/.vimrc ~/.vimrc 13 | 14 | $ git submodule update --remote 15 | ``` 16 | 17 | ## 常用快捷键 18 | 19 | + `,w` 快速保存 20 | + `:W` 保存需要权限的文件 21 | + `gg` 快速移动到文件首 22 | + `G` 快速移动至文件尾 23 | + `dd` 剪切本行 24 | + `yy` 复制本行 25 | + `:12` 快速移动至特定行 26 | + `` 移动至最近一次位置 27 | + `==i{` 自动缩进 28 | + `` 自动补全 29 | + `` 切换至最近一次窗口 30 | + `"*yy` 复制到系统剪切板 31 | + `*` 快速查找关键字,类似于sublime的 `Command + d` 32 | + `:noh` 取消关键字高亮 33 | + `:set nu` 显示行号 34 | + `:options` 显示配置 35 | 36 | ## 截屏 37 | + markdown 文件高亮与缩进 38 | 39 | ![vim-1](https://raw.githubusercontent.com/shfshanyue/vim-config/master/screenshots/vim-1.png) 40 | 41 | + solarized dark 模式 42 | 43 | ![vim-4](https://raw.githubusercontent.com/shfshanyue/vim-config/master/screenshots/vim-4.png) 44 | 45 | + [Goyo](https://github.com/junegunn/goyo.vim) 模式 46 | 47 | ![vim-2](https://raw.githubusercontent.com/shfshanyue/vim-config/master/screenshots/vim-2.png) 48 | 49 | + [ctrlp](https://github.com/kien/ctrlp.vim) 与 [nerdtree](https://github.com/scrooloose/nerdtree) 50 | 51 | ![vim-3](https://raw.githubusercontent.com/shfshanyue/vim-config/master/screenshots/vim-3.png) 52 | 53 | + git blame 效果图,插件 [vim-fugitive](https://github.com/tpope/vim-fugitive) 54 | 55 | ![vi-5](https://raw.githubusercontent.com/shfshanyue/vim-config/master/screenshots/vim-5.png) 56 | 57 | ## 插件 58 | 59 | ### [nerdtree](https://github.com/scrooloose/nerdtree) 60 | > 文件管理器 61 | 62 | + `,nn` 切换文件管理器窗口,类似于sublime的 `Command + k + b` 63 | + `,nf` 定位当前文件的位置 64 | 65 | 在文件管理窗口 66 | 67 | + `ma` 新建文件或文件夹 68 | + `md` 删除文件或文件夹 69 | + `I` 切换隐藏文件显示状态 70 | 71 | ### [ctrlp.vim](https://github.com/kien/ctrlp.vim) 72 | > ctrlp,类似于sublime的ctrlp 73 | 74 | + `` 在当前项目下查找文件 75 | + `,b` 在buffer中查找文件 76 | + `,f` 在最近打开文件中查找 77 | 78 | 在ctrlp窗口中,`` 和 `` 控制上下移动。 79 | 80 | ### [ag.vim](https://github.com/rking/ag.vim) 81 | > 查找关键字,类似于sublime的 `Command + Shift + f` 82 | 83 | + `Ag key *.js` 在特定文件下查找关键字 84 | 85 | 注:首先需要安装 [the_silver_searcher](https://github.com/ggreer/the_silver_searcher) 86 | 87 | ### [vim-commentary](https://github.com/tpope/vim-commentary) 88 | > 注释命令 89 | 90 | + `:gcc` 注释当前行,类似于sublime的 `` 91 | 92 | ### [vim-fugitive](https://github.com/tpope/vim-fugitive) 93 | > git扩展 94 | 95 | + `:Gblame` 查看当前行的归属 96 | + `:Gdiff` 查看与工作区文件的差异 97 | + `:Gread` 相当于 `git checkout -- file` 98 | + `:Gwrite` 相当于 `git add file` 99 | 100 | ### [syntastic](https://github.com/vim-syntastic/syntastic) 101 | > 语法检查插件,设置eslint 102 | 103 | + `:SyntasticCheck` 语法检查,默认会在保存时进行语法检查,不过会有卡顿 104 | + `:lne[xt]` 下一处语法错误 105 | + `:lp[revious]` 上一处语法错误 106 | + `:! eslint %:p --fix` 自动修正错误 107 | 108 | ### [emmet-vim](https://github.com/mattn/emmet-vim) 109 | > emmet扩展 110 | 111 | + `,` 类似于sublime的 `` 112 | 113 | ### [delimitMate](https://github.com/Raimondi/delimitMate) 114 | > 括号,引号自动补全 115 | 116 | ### [goyo](https://github.com/junegunn/goyo.vim) 117 | 118 | + `:Goyo` 切换至 gotyo 模式 119 | 120 | ### [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized) 121 | > solarized 主题 122 | 123 | 可更改配置文件中 background 为 `dark` 和 `light` 切换主题 124 | 125 | ## 参考 126 | 127 | + [amix/vimrc](https://github.com/amix/vimrc) 128 | -------------------------------------------------------------------------------- /screenshots/vim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shfshanyue/vim-config/dfd71b56782c141e9a9671aba6dd1c49cdfa1ede/screenshots/vim-1.png -------------------------------------------------------------------------------- /screenshots/vim-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shfshanyue/vim-config/dfd71b56782c141e9a9671aba6dd1c49cdfa1ede/screenshots/vim-2.png -------------------------------------------------------------------------------- /screenshots/vim-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shfshanyue/vim-config/dfd71b56782c141e9a9671aba6dd1c49cdfa1ede/screenshots/vim-3.png -------------------------------------------------------------------------------- /screenshots/vim-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shfshanyue/vim-config/dfd71b56782c141e9a9671aba6dd1c49cdfa1ede/screenshots/vim-5.png -------------------------------------------------------------------------------- /undo_dirs/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | --------------------------------------------------------------------------------