vim
Caution
todo…
1 配置
~/.vimrc
" basic settings
set history=500
set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nobackup "不备份
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set nu
set foldenable " 允许折叠
set foldmethod=manual " 手动折叠
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
syntax on
let $LANG='en'
set langmenu=en
let g:coc_global_extensions = [
\ "coc-explorer",
\ "coc-translator",
\ "coc-python",
\ "coc-vimlsp",
\ "coc-gitignore",
\ "coc-json",
\ "coc-rust-analyzer",
\ "coc-go",
\ "coc-yaml",
\ "coc-syntax",
\ "coc-html"
\ ]
autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.organizeImport')
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" 提示 主动的快捷键
if has('nvim')
inoremap <silent><expr> <c-o> coc#refresh()
else
inoremap <silent><expr> <c-o> coc#refresh()
endif
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
"nnoremap <silent> <LEADER>h :call <SID>show_documentation()<CR>
nnoremap <silent> K :call <SID>show_documentation()<CR>
nnoremap tt :CocCommand explorer<CR>
" coc-translator
nmap ts <Plug>(coc-translator-p)
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Run the Code Lens action on the current line.
nmap <leader>cl <Plug>(coc-codelens-action)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
"set clipboard+=unnamed
" Turn on the WiLd menu
"set wildmenu
" Ignore compiled files
"set wildignore=*.o,*~,*.pyc
"if has("win16") || has("win32")
" set wildignore+=.git\*,.hg\*,.svn\*
"else
" set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
"endif
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
"set undofile " keep an undo file (undo changes after closing)
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
"set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" rust
autocmd Filetype rust set foldmethod=syntax
" SYNTAX HIGHLIGHTING:
set t_Co=256
"syntax on
"colorscheme ir_black
set bs=2
filetype off " required
" set the runtime path to include Vundle and initialize
"set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#begin()
"call vundle#begin('~/some/path/here')
call plug#begin()
"Plugin 'VundleVim/Vundle.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tomtom/tcomment_vim' "in <space>cn to comment a line
" type yskw' to wrap the word with '' or type cs'` to change 'word' to `word`
Plug 'tpope/vim-surround'
" in Visual mode, type k' to select all text in '', or type k) k] k} kp
Plug 'gcmt/wildfire.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'tpope/vim-fugitive'
Plug 'bling/vim-airline'
" 在 Vim 中快速导航文件,好像需要ruby支持,暂时不按照
" Plugin 'git://git.wincent.com/command-t.git'
"Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
Plug 'rust-lang/rust.vim'
"Bundle 'Rykka/riv.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'nvim-treesitter/nvim-treesitter'
" pretty dress
Plug 'theniceboy/nvim-deus'
Plug 'scrooloose/nerdtree'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'wellle/tmux-complete.vim'
" 这个插件可以显示文件的 Git 增删状态
Plug 'Xuyuanp/nerdtree-git-plugin'
"Plugin 'user/L9', {'name': 'newL9'}
"Plug 'scrooloose/syntastic'
Plug 'tpope/vim-markdown'
Plug 'mattn/emmet-vim'
Plug 'kien/rainbow_parentheses.vim'
Plug 'godlygeek/tabular'
Plug 'Yggdroot/indentLine'
Plug 'majutsushi/tagbar'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
call plug#end()
"call vundle#end() " required
filetype plugin indent on " required
set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types\ 12
set nu
let mapleader=';'
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab "将tab替换为相应数量空格
set smartindent
set encoding=utf8 "设置内部编码为utf8
set fileencoding=utf8 "当前编辑的文件编码
set fileencodings=uft8-bom,utf8,gbk,gb2312,big5 "打开支持编码的文件
set backspace=2 "可随时用倒退键删除
"imap ;; <ESC>
"cmap ;; <ESC>
vmap <C-c> "+y
set cursorline
set hlsearch
set incsearch
set showmatch
set report=0
set laststatus=2
let g:airline_powerline_fonts = 1
"let g:airline_symbols
"let g:airline_left_sep='▶'
"let g:airline_right_sep='◀'
let g:airline#extensions#tabline#enabled = 1
syntax enable
" 如果是在xshell下vim 这里需要打开
" 百度搜索 xshell vim solarized
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
"let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\}
map <F3> :NERDTreeToggle<CR>
" 可直接复制到系统剪贴板
set clipboard=unnamed
"autocmd vimenter * NERDTree
let g:NERDTreeDirArrowExpandable = '❤'
let g:NERDTreeDirArrowCollapsible = '▼'
let g:NERDTreeGitStatusIndicatorMapCustom= {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ "Unknown" : "?"
\ }
let g:autoclose_vim_commentmode = 1
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:user_emmet_install_global = 0
let g:syntastic_ignore_files=[".*\.rst$"]
autocmd FileType html,css EmmetInstall
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 36
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"let g:indent_guides_auto_colors = 1
"let g:indent_guides_enable_on_vim_startup = 1
let g:indentLine_color_term = 239
let g:indentLine_enabled = 1
"ctrlp
nnoremap <silent> <Leader>f :CtrlPMRU<CR>
nnoremap <silent> <Leader>b :CtrlPBuffer<CR>
" 窗口切换
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
"设置撤销的目录
set undodir=/tmp/vimundodir
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q<CR>
inoremap <c-a> <ESC>0i
"inoremap <c-e> <ESC>$a
"map <F5> :!javac %&&java %:r <CR>
hi MatchParen cterm=bold ctermbg=none ctermfg=magenta
let g:UltiSnipsExpandTrigger="<c-y>"
"let g:vimim_cloud = 'sogou'
"tagbar settings
" vim php文件时,按下F8即可
" http://ctags.sourceforge.net/
" 进入某个code目录 ctags -R 生成tags
" " 进入代码目录 ctags -R 生成tags文件
" 打开代码 F8 即可打开右侧
" ctrl + ] 跳转定义
" ctrl + t 调回原来的地方
" nmap 表示 正常模式, n normal
"nmap <M-d> <ctrl-]>
" 配置插入模式下 也使用ctrl+] 来跳转
imap <c-]> <Esc><c-]>
nmap <F8> :TagbarToggle<CR>
let g:tagbar_ctags_bin = 'ctags'
let g:tagbar_width = 30
" 需要复制一堆东西到vim打开的文件时,会乱了格式,这个就是解决这个问题
" F10 来切换
set pastetoggle=<F10>
"inoremap ( ()<ESC>i
"inoremap [ []<ESC>i
"inoremap { {}<ESC>i
"inoremap < <><ESC>i2 vimdiff时的快捷键
| 快捷键 | 功能 |
|---|---|
| ctrl + w ,再按 l 切换到右侧 | 切换到右边的窗口 |
| ctrl + w ,再按 h 切换到左侧 | 切换到左边的窗口 |
3 ipad esc 键怎么按
- 没有 这个键, 用 ctrl+[ 或 cmd+.来代替 ESC键
- 或者在 设置中 通用->键盘->实体键盘->修饰键 改大写锁定键=>ESC
4 nerdtree
- 窗口切换快捷键
- 窗口设置大小