Last active
October 9, 2024 07:58
-
-
Save lbj96347/1388268 to your computer and use it in GitHub Desktop.
vim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on " 语法高亮 | |
" 设置文件编码为 utf-8 | |
set encoding=utf-8 | |
" 设置终端编码为 utf-8 | |
set termencoding=utf-8 | |
" 设置文件读写编码为 utf-8 | |
set fileencoding=utf-8 | |
" 设置文件编码自动检测顺序 | |
set fileencodings=utf-8,latin1 | |
filetype plugin indent on " 文件类型检测 | |
autocmd BufEnter * :syntax sync fromstart | |
let mapleader="," | |
set clipboard=unnamed | |
set nocompatible " 关闭兼容模式 | |
set autoindent " 打开自动缩,继承前一行的缩进方式,特别适用于多行注释 | |
set nu " 显示行号 | |
set showcmd " 显示命令 | |
set noswapfile " 不使用swp文件 | |
set nobackup " 关闭备份 | |
set incsearch " 增量式搜索 | |
set hlsearch " 高亮搜索 | |
set ignorecase " 搜索时忽略大小写 | |
set magic " 额,自己:h magic吧,一行很难解释 | |
set showmatch " 显示匹配的括号 | |
set nowb | |
set lbr " 在breakat字符处而不是最后一个字符处断行 | |
set ai " 自动缩进 | |
set si " 智能缩进 | |
set history=100 " vim记住的历史操作的数量,默认的是20 | |
set autoread " 当文件在外部被修改时,自动重新读取 | |
set mouse=a " 在所有模式下都允许使用鼠标,还可以是n,v,i,c等 | |
set guioptions-=R " 隐藏右边滚动条 | |
set formatoptions+=mM " 正确地处理中文字符的折行和拼接 | |
set whichwrap+=<,>,h,l " 退格键和方向键可以换行 | |
set fileencodings=utf-8 " 文件UTF-8编码 | |
set pastetoggle=<F2> " 切换粘贴模式 | |
set backspace=indent "fix the backspace" | |
set backspace=2 | |
set syntax=jade " 需要安装 vim-jade | |
" 设置缩进 | |
set expandtab | |
set smarttab | |
set shiftwidth=2 | |
set tabstop=2 | |
" 自动完成括号和引号 | |
inoremap <leader>1 ()<esc>:let leavechar=")"<cr>i | |
inoremap <leader>2 []<esc>:let leavechar="]"<cr>i | |
inoremap <leader>3 {}<esc>:let leavechar="}"<cr>i | |
inoremap <leader>4 {<esc>o}<esc>:let leavechar="}"<cr>O | |
inoremap <leader>q ''<esc>:let leavechar="'"<cr>i | |
inoremap <leader>w ""<esc>:let leavechar='"'<cr>i | |
" ^z快速进入shell | |
nmap <C-Z> :shell<cr> | |
" 把F4作为JSHint的启动按键 | |
nmap <F4> :JSHint | |
" 把空格键映射成: | |
nmap <space> : | |
" F8启动NERDTree插件 | |
map <F8> :NERDTree<CR> | |
" F9启动taglist插件 | |
nnoremap <silent> <F9> :TlistToggle<CR> | |
" 在文件名上按gf时,在新的tab中打开 | |
" map gf :tabnew <cfile><cr> | |
" Tab和Shift-Tab缩进 | |
nmap <tab> v> | |
nmap <s-tab> v< | |
vmap <tab> >gv | |
vmap <s-tab> <gv | |
" CTRL-C are Copy | |
vnoremap <C-C> "+y | |
" CTRL-V are Paste | |
map <C-V> "+gP | |
cmap <C-V> <C-R>+ | |
imap <C-V> <C-R>+ | |
" strip all trailing whitespace in the current file | |
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> | |
" reselect the text that was just pasted | |
nnoremap <leader>V V`] | |
" 水平分割窗口 | |
nnoremap <leader>s <C-w>s | |
" 垂直分割窗口 | |
nnoremap <leader>v <C-w>v | |
" ack | |
nnoremap <leader>a :Ack | |
" Display the contents of the yankring | |
nnoremap <leader>y :YRShow<CR> | |
" 窗口区域切换,Ctrl+jkhl 来切换 | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" 窗口区域切换,Ctrl+↑↓←→ 来切换 | |
imap <silent> <C-left> <esc><C-W><left> | |
vmap <silent> <C-left> <esc><C-W><left> | |
nmap <silent> <C-left> <C-W><left> | |
imap <silent> <C-right> <esc><C-W><right> | |
vmap <silent> <C-right> <esc><C-W><right> | |
nmap <silent> <C-right> <C-W><right> | |
imap <silent> <C-up> <esc><C-W><up> | |
vmap <silent> <C-up> <esc><C-W><up> | |
nmap <silent> <C-up> <C-W><up> | |
imap <silent> <C-down> <esc><C-W><down> | |
vmap <silent> <C-down> <esc><C-W><down> | |
nmap <silent> <C-down> <C-W><down> | |
"colorscheme blackboard " 使用blackboard插件的配色 | |
:filetype plugin on " 启动snipMate插件 | |
:filetype indent on " 启动snipMate插件 | |
" taglist插件配置 | |
let Tlist_Show_One_File=1 " 不同时显示多个文件的tag,只显示当前文件的 | |
let Tlist_Exit_OnlyWindow=1 " 如果taglist窗口是最后一个窗口,则退出vim | |
let Tlist_Use_Right_Window=1 " 在右侧窗口中显示taglist窗口 | |
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS | |
autocmd FileType python set omnifunc=pythoncomplete#Complete | |
autocmd FileType javascrīpt set omnifunc=javascrīptcomplete#CompleteJS | |
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags | |
autocmd FileType css set omnifunc=csscomplete#CompleteCSS | |
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags | |
autocmd FileType php set omnifunc=phpcomplete#CompletePHP | |
autocmd FileType c set omnifunc=ccomplete#Complete | |
autocmd BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} map <Leader>p :!open "/Applications/Google\ Chrome.app/" "%:p"<CR> | |
" 为 Javascript 文件自动增加注释 | |
map <F3> :call AddReadMe()<cr>'s | |
function AddReadMe() | |
call setline(1,"/**") | |
call append(1," * @require : none") | |
call append(2," * @author : [email protected]") | |
call append(3," * @date : " . strftime("%Y-%m-%d")) | |
call append(4," * @description : this is a new file ") | |
call append(5," */") | |
endf | |
" Install Vundel | |
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'christoomey/vim-system-copy' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
" plugin on GitHub repo | |
Plugin 'tpope/vim-fugitive' | |
" support React tsx highlight | |
Plugin 'leafgarland/typescript-vim' | |
Plugin 'peitalin/vim-jsx-typescript' | |
" plugin from http://vim-scripts.org/vim/scripts.html | |
" Plugin 'L9' | |
" The sparkup vim script is in a subdirectory of this repo called vim. | |
" Pass the path to set the runtimepath properly. | |
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} | |
" Install L9 and avoid a Naming conflict if you've already installed a | |
" different version somewhere else. | |
" Plugin 'ascenator/L9', {'name': 'newL9'} | |
" Bundle 'Valloric/YouCompleteMe' | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" To ignore plugin indent changes, instead use: | |
"filetype plugin on | |
" | |
" Brief help | |
" :PluginList - lists configured plugins | |
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate | |
" :PluginSearch foo - searches for foo; append `!` to refresh local cache | |
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" Put your non-Plugin stuff after this line | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment