vim 探索之旅

本人在vim遇到的问题和探索, 从下载插件到编译安装,遇到较多问题, 满满的干货,总结如下分下给大家:闲余有好插件将继续一直更新,让我们领会vim强大和便捷。

1.FZF

2.YouCompleteMe

1.FZF模糊查找插件

Plugin 'junegunn/fzf'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
:PluginInstall 安装插件

   常用命令

let g:fzf_preview_window = ['right:50%', 'ctrl-/']
let g:fzf_preview_window=['up:40%:hidden',"ctrl-/"]
let g:fzf_preview_window=[]

        noremap  <C-p> :FZF<CR>

        noremap  <C-f> :Ag<CR>

         noremap  <C-f> :MRU<CR>

        noremap  <C-h> :BTags<CR>

         noremap  <C-l> : LinesWithPreview<CR>   

         noremap  <C-w> : Buffers<CR>   

         nmap h :History<CR>

         auocmd!  FileType fzf

FZF   [path]

 制定路径下搜索 当前目录与子目录

History 命令

FZF 配置文件如下:

let g:fzf_command_prefix = 'Fzf'
let g:fzf_buffers_jump = 1      " [Buffers] to existing split

function! s:build_location_list(lines) abort
    call setloclist(0, map(copy(a:lines), '{ "filename": v:val }'))
    lopen
endfunction

function! s:build_quickfix_list(lines) abort
    call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
    copen
endfunction

" An action can be a reference to a function that processes selected lines
let g:fzf_action = {
            \ 'ctrl-l': function('s:build_quickfix_list'),
            \ 'ctrl-r': function('s:build_location_list'),
            \ 'ctrl-t': 'tab split',
            \ 'ctrl-x': 'split',
            \ 'ctrl-v': 'vsplit'}
" \ 'ctrl-o': '<S-tab>',
" \ 'ctrl-i': 'insert_match',

" function! s:insert_match(lines) abort
"   <c-r>=echo('a:lines')<cr>
" endfunction

nnoremap <leader>ff :FzfFiles $HOME<cr>
nnoremap <leader><c-f> :FzfFiles .<cr>
nnoremap <leader>F :FzfFiles /<cr>
nnoremap <leader>fb :FzfBuffers<cr>
nnoremap <leader>b :FzfBuffers<cr>
nnoremap <leader>fw :FzfWindows<cr>
nnoremap <leader>ft :FzfTags<cr>
nnoremap <leader>f<c-t> :FzfBTags<cr>
nnoremap <leader>fc :FzfCommit<cr>
nnoremap <leader>f<c-c> :FzfBCommit<cr>
nnoremap <leader>fg :FzfGFiles?<cr>
nnoremap <leader>f<c-g> :FzfGFiles<cr>
nnoremap <leader>fl :FzfLines<cr>
nnoremap <leader>f<c-l> :FzfBLines<cr>
nnoremap <leader>f; :FzfHistory:<cr>
nnoremap <leader>f/ :FzfHistory/<cr>
nnoremap <leader>fh :FzfHistory<cr>
nnoremap <leader>fm :FzfHelptags<cr>
nnoremap <leader>fs <esc>:FzfSnippets<cr>
nnoremap <leader>fr <esc>:Rg<cr>
inoremap <c-x><c-s> <c-o>:FzfSnippets<cr>

" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'

let g:fzf_tags_command = 'ctags -R'
" Border color
let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'rounded' } }

let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline --bind "ctrl-o:toggle+up,ctrl-space:toggle-preview"'
let $FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/**'"
"-g '!{node_modules,.git}'

" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg':      ['fg', 'Normal'],
    \ 'bg':      ['bg', 'Normal'],
    \ 'gutter':  ['bg', 'Normal'],
    \ 'hl':      ['fg', 'Comment'],
    \ 'fg+':     ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
    \ 'bg+':     ['bg', 'Visual', 'CursorColumn'],
    \ 'hl+':     ['fg', 'Statement'],
    \ 'info':    ['fg', 'PreProc'],
    \ 'border':  ['fg', 'vertsplit'],
    \ 'prompt':  ['fg', 'Conditional'],
    \ 'pointer': ['fg', 'Exception'],
    \ 'marker':  ['fg', 'Keyword'],
    \ 'spinner': ['fg', 'Label'],
    \ 'header':  ['fg', 'Comment'] }
    " \ 'border':  ['fg', 'Conditional'],

"Get Files
command! -bang -nargs=? -complete=dir Files
        \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)

" Get text in files with Rg
command! -bang -nargs=* Rg
    \ call fzf#vim#grep(
    \   "rg --column --line-number --no-heading --color=always --smart-case --glob '!.git/**' ".shellescape(<q-args>), 1,
    \   fzf#vim#with_preview(), <bang>0)

" Ripgrep advanced
function! RipgrepFzf(query, fullscreen) abort
    let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
    let initial_command = printf(command_fmt, shellescape(a:query))
    let reload_command = printf(command_fmt, '{q}')
    let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
    call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction

command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)

" Git grep
command! -bang -nargs=* GGrep
    \ call fzf#vim#grep(
    \   'git grep --line-number '.shellescape(<q-args>), 0,
    \   fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)

2.安装插件YouCompleteMe

   

下载的插件放入.vim/bundle/ 目录下面

git clone GitHub - ycm-core/YouCompleteMe: A code-completion engine for Vim ~/.vim/bundle

 在~/.vimrc 中添加

Plugin 'Valloric/YouCompleteMe'

 

YouCompleteMe实现vim自动补全

YouCompleteMe实现vim自动补全_安装youcompleteme使用vim c/c++语法自动补全-CSDN博客

安装需要注意升级python cmake   c++  版本

安装YCM报错

2.1 Python headers are missing in /usr/include/python3.8. 解决

sudo apt-get install python3.8-dev

 2.2CMake 3.14 or higher is required

  ubuntu 14.04下安装cmake 3.2.2(自带版本2.8.2)

cmake 网站:
https://cmake.org/files/
方法二:
wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz
tar xf cmake-3.2.2.tar.gz
cd cmake-3.2.2
./configure
make
sudo make install

2.3  Your C++ compiler does NOT fully support C++17

 

 

sudo apt-get install g++-8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8

2.4: file DOWNLOAD HASH mismatch

cd   YouCompleteMe/third_party/ycmd/clang_archives 下

需要 修改libclang-17.0.1-x86_64-unknown-linux-gnu.tar.bz2 名称

使用命令重新下载 图中的链接地址包

wget    https://github.com/ycm-core/llvm/releases/download/17.0.1/libclang-17.0.1-x86_64-unknown-linux-gnu.tar.bz2

2.5 .C++ compiler 安装

Your C++ compiler does NOT fully support C++17,升级gcc到支持c++17

	sudo apt-get install g++-8

2.6 C++: fatal error: Killed signal terminated program cc1plus

        编译失败 内存不足 调大内存

2.7 . youcompleteme 无反应  查看log

 

        version `GLIBC_2.29' not found

         安装GLIBC_2.29

【请谨慎操作】Ubuntu18.04升级GLIBC_2.29,解决ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29‘-CSDN博客

tar -zxvf glibc-2.29.tar.gz

cd glibc-2.29

mkdir build

cd build/

../configure --prefix=/usr/local --disable-sanity-checks

2.8 编译出现:.hese critical programs are missing or too old: gawk bison

安装这个gawk bison 这个插件

sudo apt install gawk

sudo apt install bison

 2.9.libstdc++.so.6.0.x库文件已不存在

 

解决/usr/lib/libstdc++.so.6: version `GLIBCXX_3.x.x‘ not found问题-CSDN博客

根据Youcompleteme  的log 信息

/usr/lib/x86_64-linux-gnu/libstdc++.so.6

删除旧的连接

创建新的连接

sudo ln -s libstdc++.so.6.0.26 libstdc++.so.6

装好后OK 插件正常功能。


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值