在配置ubuntu的vimrc时,添加了如下设置,导致vim里面ctrl+shift+c和ctrl+shift+v无效了,删除这个vimrc之后,该bug又恢复了,请问是哪个语句限制了这两个快捷键的使用?
" 加载janah主题配色
"syntax enable
"colorscheme janah
" 开启语法高亮
syntax on
" 开启鼠标支持
set mouse=a
" 设置 tab 宽度为 4 个空格
set tabstop=4
" 设置自动缩进宽度为 4 个空格
set shiftwidth=4
" 开启自动缩进
set autoindent
" 显示行号
set number
" 显示当前行号/总行数
set ruler
" 智能缩进
"set smartindent
" 开启搜索高亮
set hlsearch
" 设置搜索忽略大小写
set ignorecase
" 设置命令模式下的补全
set wildmenu
" 开启文件类型检测
filetype on
" 自动判断文件编码
set fileencodings=utf-8,gbk
" 快速保存
nnoremap :w
" 快速退出
nnoremap :q
" 设置快捷键,快速跳转到行首/行尾插入
nnoremap ^i
nnoremap $a
" 打开所在行横线提示
set cursorline
" 在文件中插入时间戳
autocmd BufNewFile * execute "normal i" . "// date: "
autocmd BufNewFile * execute "normal i" . strftime("%c") . "\r"
" 在文件中插入名字
autocmd BufNewFile * execute "normal i" ."// author: keeshow". "\r"
" 在文件中插入文件路径
autocmd BufNewFile * execute "normal i" . "// path: "
autocmd BufNewFile * execute "normal i" .expand("%:p")
if has("autocmd")
" 在新建 C 文件时,插入 C 语言模板
autocmd BufNewFile *.c $read ~/.vim/templates/skeleton.c
endif
使用二分法。
参考下面:
偶遇到类似问题都是用
“每次用/.../注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。
.viimrc一般放置在家目录下,即该文件路径一般为~/.vimrc
具体配置可参考
""""""coc-vim setting"""""""""""""""
let g:coc_disable_startup_warning = 1
let g:coc_global_extensions = ['coc-tsserver','coc-html','coc-css', 'coc-json',
\ 'coc-java','coc-python','coc-flutter','coc-clangd','coc-cmake','coc-go',
\ 'coc-emmet','coc-snippets','coc-xml','coc-yaml','coc-git',
\ 'coc-markdownlint','coc-highlight']
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Or use `complete_info` if your vim support it, like:
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
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> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>fm <Plug>(coc-format-selected)
nmap <leader>fm <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
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Create mappings for function text object, requires document symbols feature of languageserver.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
nmap <silent> <C-d> <Plug>(coc-range-select)
xmap <silent> <C-d> <Plug>(coc-range-select)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Using CocList
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
let mapleader=" "
syntax on
set number
set norelativenumber
set cursorline
set wrap
set showcmd
set wildmenu
set hlsearch
exec "nohlsearch"
set incsearch
set ignorecase
set smartcase
set nocompatible
filetype on
filetype indent on
filetype plugin on
filetype plugin indent on
set mouse=a
set encoding=utf-8
let &t_ut=''
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set list
set listchars=tab:▸\ ,trail:▫
set scrolloff=5
set tw=0
set indentexpr=
set backspace=indent,eol,start
set foldmethod=indent
set foldlevel=99
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
set laststatus=2
"set tags=tags
set autochdir
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
noremap = nzz
noremap - Nzz
noremap <LEADER><CR> :nohlsearch<CR>
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
"设置C/C++方式自动对齐
set autoindent
set cindent
"noremap n h
"noremap u k
"noremap e j
"noremap i l
"noremap U 5k
noremap E 5j
noremap N 7h
noremap I 7l
" N key: go to the start of the line
noremap <C-n> 0
" I key: go to the end of the line
noremap <C-i> $
"noremap k i
"noremap K I
"noremap l u
map s <nop>
map S :w<CR>
map Q :q<CR>
map R :source $MYVIMRC<CR>
map ; :
map si :set splitright<CR>:vsplit<CR>
map sn :set nosplitright<CR>:vsplit<CR>
map su :set nosplitbelow<CR>:split<CR>
map se :set splitbelow<CR>:split<CR>
map <LEADER>i <C-w>l
map <LEADER>u <C-w>k
map <LEADER>n <C-w>h
map <LEADER>e <C-w>j
map <up> :res +5<CR>
map <down> :res -5<CR>
map <left> :vertical resize-5<CR>
map <right> :vertical resize+5<CR>
map tu :tabe<CR>
map tn :-tabnext<CR>
map ti :+tabnext<CR>
map sv <C-w>t<C-w>H
map sh <C-w>t<C-w>K
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'connorholyday/vim-snazzy'
" coc extensions
Plug 'neoclide/coc-git', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
" File navigation
Plug 'scrooloose/nerdtree' " , { 'on': 'NERDTreeToggle' }
Plug 'vim-scripts/taglist.vim'
Plug 'Xuyuanp/nerdtree-git-plugin'
" Taglist
Plug 'majutsushi/tagbar', { 'on': 'TagbarOpenAutoClose' }
" Error checking
Plug 'w0rp/ale'
" Auto Complete
"Plug 'Valloric/YouCompleteMe'
" ------coc-vim------------
" Use release branch (Recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
""""""""vim-clang(for C++)-------
Plug 'justmao945/vim-clang'
" Or latest tag
"Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'}
" Or build from source code by use yarn: https://yarnpkg.com
"Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
" -------coc-vim-----------
" Undo Tree
Plug 'mbbill/undotree/'
" Other visual enhancement
Plug 'nathanaelkane/vim-indent-guides'
Plug 'itchyny/vim-cursorword'
" Git
Plug 'rhysd/conflict-marker.vim'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'gisphm/vim-gitignore', { 'for': ['gitignore', 'vim-plug'] }
" HTML, CSS, JavaScript, PHP, JSON, etc.
Plug 'elzr/vim-json'
Plug 'hail2u/vim-css3-syntax'
Plug 'spf13/PIV', { 'for' :['php', 'vim-plug'] }
Plug 'gko/vim-coloresque', { 'for': ['vim-plug', 'php', 'html', 'javascript', 'css', 'less'] }
Plug 'pangloss/vim-javascript', { 'for' :['javascript', 'vim-plug'] }
Plug 'mattn/emmet-vim'
" Python
Plug 'vim-scripts/indentpython.vim'
" Markdown
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install_sync() }, 'for' :['markdown', 'vim-plug'] }
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle' }
Plug 'vimwiki/vimwiki'
" Bookmarks
Plug 'kshenoy/vim-signature'
" Other useful utilities
Plug 'terryma/vim-multiple-cursors'
Plug 'junegunn/goyo.vim' " distraction free writing mode
Plug 'tpope/vim-surround' " type ysks' to wrap the word with '' or type cs'` to change 'word' to `word`
Plug 'godlygeek/tabular' " type ;Tabularize /= to align the =
Plug 'gcmt/wildfire.vim' " in Visual mode, type i' to select all text in '', or type i) i] i} ip
Plug 'scrooloose/nerdcommenter' " in <space>cc to comment a line
" Dependencies
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'kana/vim-textobj-user'
Plug 'fadein/vim-FIGlet'
" tags
"Plug 'universal-ctags/ctags'
"Plug 'ludovicchabant/vim-gutentags'
call plug#end()
let g:SnazzyTransparent = 1
color snazzy
"colorscheme slate "peachpuff "koehler "blue "desert
"""""""透明度"""""""""""
hi Normal ctermfg=252 ctermbg=none
" ===
" === NERDTree
" ===
map tt :NERDTreeToggle<CR>
let NERDTreeMapOpenExpl = ""
let NERDTreeMapUpdir = ""
let NERDTreeMapUpdirKeepOpen = "l"
let NERDTreeMapOpenSplit = ""
let NERDTreeOpenVSplit = ""
let NERDTreeMapActivateNode = "i"
let NERDTreeMapOpenInTab = "o"
let NERDTreeMapPreview = ""
let NERDTreeMapCloseDir = "n"
let NERDTreeMapChangeRoot = "y"
" ==
" == NERDTree-git
" ==
"->NERDTree目录树插件---配置选项=====================================================
let g:NERDTreeDirArrowExpandable = '▸' "目录图标
let g:NERDTreeDirArrowCollapsible = '▾'
"autocmd vimenter * NERDTree "自动打开目录树
"vim【无文件】也显示目录树
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"vim打开目录文件也显示目录树?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
"CRTL+N开关目录树
map <C-n> :NERDTreeToggle<CR>
"关闭最后一个文件,同时关闭目录树
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ "Unknown" : "?"
\ }
"<-NERDTree目录树插件---配置选项===============================================================
" ===
" === You Complete ME
" ===
"nnoremap gd :YcmCompleter GoToDefinitionElseDeclaration<CR>
"nnoremap g/ :YcmCompleter GetDoc<CR>
"nnoremap gt :YcmCompleter GetType<CR>
"nnoremap gr :YcmCompleter GoToReferences<CR>
"let g:ycm_autoclose_preview_window_after_completion=0
"let g:ycm_autoclose_preview_window_after_insertion=1
"let g:ycm_use_clangd = 0
""let g:ycm_python_interpreter_path = "/bin/python3"
"let g:ycm_python_interpreter_path = "/usr/bin/python3"
""let g:ycm_python_binary_path = "/bin/python3"
":let g:ycm_python_binary_path = "/usr/bin/python3"
" ===
" === ale
" ===
let b:ale_linters = ['pylint']
let b:ale_fixers = ['autopep8', 'yapf']
" ===
" === Taglist
" ===
map <silent> T :TagbarOpenAutoClose<CR>
"->taglist浏览插件配置=========================================
"taglist窗口显示在右侧,缺省为左侧
let Tlist_Use_Right_Window=1
"设置ctags路径"将taglist与ctags关联
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
"启动vim后自动打开taglist窗口
let Tlist_Auto_Open = 1
"不同时显示多个文件的tag,只显示当前文件的
"不同时显示多个文件的tag,仅显示一个
let Tlist_Show_One_File = 1
"taglist为最后一个窗口时,退出vim
let Tlist_Exit_OnlyWindow = 1
"let Tlist_Use_Right_Window =1
"设置taglist窗口大小
"let Tlist_WinHeight = 100
let Tlist_WinWidth = 40
"设置taglist打开关闭的快捷键F8
noremap <F8> :TlistToggle<CR>
"更新ctags标签文件快捷键设置
noremap <F6> :!ctags -R<CR>
"<-taglist=========================================
" ===
" === MarkdownPreview
" ===
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 0
let g:mkdp_open_to_the_world = 0
let g:mkdp_open_ip = ''
let g:mkdp_browser = 'chromium'
let g:mkdp_echo_preview_url = 0
let g:mkdp_browserfunc = ''
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1
\ }
let g:mkdp_markdown_css = ''
let g:mkdp_highlight_css = ''
let g:mkdp_port = ''
let g:mkdp_page_title = '「${name}」'
" ===
" === vim-table-mode
" ===
map <LEADER>tm :TableModeToggle<CR>
" ===
" === Python-syntax
" ===
let g:python_highlight_all = 1
" let g:python_slow_sync = 0
" ===
" === vim-indent-guide
" ===
let g:indent_guides_guide_size = 1
let g:indent_guides_start_level = 2
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_color_change_percent = 1
silent! unmap <LEADER>ig
autocmd WinEnter * silent! unmap <LEADER>ig
" ===
" === Goyo
" ===
map <LEADER>gy :Goyo<CR>
" ===
" === vim-signiture
" ===
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "dm-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "dm/",
\ 'PurgeMarkers' : "dm?",
\ 'GotoNextLineAlpha' : "m<LEADER>",
\ 'GotoPrevLineAlpha' : "",
\ 'GotoNextSpotAlpha' : "m<LEADER>",
\ 'GotoPrevSpotAlpha' : "",
\ 'GotoNextLineByPos' : "",
\ 'GotoPrevLineByPos' : "",
\ 'GotoNextSpotByPos' : "mn",
\ 'GotoPrevSpotByPos' : "mp",
\ 'GotoNextMarker' : "",
\ 'GotoPrevMarker' : "",
\ 'GotoNextMarkerAny' : "",
\ 'GotoPrevMarkerAny' : "",
\ 'ListLocalMarks' : "m/",
\ 'ListLocalMarkers' : "m?"
\ }
" ===
" === Undotree
" ===
let g:undotree_DiffAutoOpen = 0
map L :UndotreeToggle<CR>
" ===
" === gutentags
" ===
" gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
"let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" 所生成的数据文件的名称
"let g:gutentags_ctags_tagfile = '.tags'
" 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
"let s:vim_tags = expand('~/.cache/tags')
"let g:gutentags_cache_dir = s:vim_tags
" 配置 ctags 的参数
"let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
"let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
"let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 检测 ~/.cache/tags 不存在就新建
"if !isdirectory(s:vim_tags)
" silent! call mkdir(s:vim_tags, 'p')
"endif
" ===
" === universial ctags
" ===
"let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
"let g:gutentags_ctags_extra_args += ['--c++-kinds=+pxI']
"let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" ===
" === vim-clang
" ===
"vim-clang
"开启对C11和C++11的支持
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11 -stdlib=libc++'
"关闭语法检查
let g:clang_check_syntax_auto = 0
"不要自动格式化代码
let g:clang_format_auto = 0
"代码格式化风格选项依次有LLVM,Google,Chromium,Mozilla,WebKit
"let g:clang_format_style = 'LLVM'
"使得vim-clang的补全与其他IDE一致
let g:clang_cpp_completeopt = 'longest,menuone,preview'