[新增] 新增vim使用文档, 优化vim配置, 添加快捷键说明, 修复git和vim部分情况下中文显示utf8编码而不是可读文字的问题
This commit is contained in:
parent
ece03cda86
commit
1e89186e6e
11
安装.zsh
11
安装.zsh
|
@ -117,10 +117,14 @@ readonly 系统一发行版一名称=$(echo "${NAME}")
|
|||
色彩一灰色
|
||||
rm -vrf ${vim一配置路径}
|
||||
mkdir -vp ${vim一配置路径}/{opt,start}
|
||||
vim说明=${目录一根}/配置/vim配置说明.vim
|
||||
git clone --depth 1 https://gitcode.com/mirrors/scrooloose/nerdtree.git ${vim一配置路径}/start/树状目录
|
||||
git clone --depth 1 https://gitcode.com/dense-analysis/ale.git ${vim一配置路径}/start/代码检查工具
|
||||
git clone --depth 1 https://gitcode.com/jiangmiao/auto-pairs.git ${vim一配置路径}/start/括号补齐
|
||||
git clone --depth 1 https://gitcode.com/Yggdroot/LeaderF.git ${vim一配置路径}/start/模糊搜索器
|
||||
if 是否 "是否启用基于c的模糊搜索(默认使用python, c的性能会好很多)"; then
|
||||
vim -c ":LeaderfInstallCExtension" ${vim说明}
|
||||
fi
|
||||
git clone --depth 1 https://gitcode.com/mirrors/ludovicchabant/vim-gutentags.git ${vim一配置路径}/start/标签生成器
|
||||
if 是否 "是否需要安装vim代码补全工具(代码补全工具需要nodejs支持, 如找不到nodejs脚本将会自动安装)"; then
|
||||
输出 2 "默认会安装 shell c/c++ cmake go java json markdown perl python r rust 语言的补全"
|
||||
|
@ -129,8 +133,8 @@ readonly 系统一发行版一名称=$(echo "${NAME}")
|
|||
# todo: 这里调用一个nodejs的检查工具
|
||||
# 编译和启动
|
||||
npm -C ${vim一配置路径}/start/代码补全 i && npm -C ${vim一配置路径}/start/代码补全 ci
|
||||
vim -c ":CocInstall coc-sh coc-clangd coc-cmake coc-go coc-json coc-java coc-markdownlint coc-perl coc-pyright coc-r-lsp coc-rls" ${目录一根}/配置/vim配置说明.vim
|
||||
是否 "是否安装前端相关代码补全工具(html css js/ts vue)" && vim -c ":CocInstall coc-css coc-html coc-tsserver coc-vetur" ${目录一根}/配置/vim配置说明.vim
|
||||
vim -c ":CocInstall coc-sh coc-clangd coc-cmake coc-go coc-json coc-java coc-markdownlint coc-perl coc-pyright coc-r-lsp coc-rls" ${vim说明}
|
||||
是否 "是否安装前端相关代码补全工具(html css js/ts vue)" && vim -c ":CocInstall coc-css coc-html coc-tsserver coc-vetur" ${vim说明}
|
||||
fi
|
||||
git clone --depth 1 https://gitcode.com/mirrors/preservim/nerdcommenter.git ${vim一配置路径}/start/注释工具
|
||||
git clone --depth 1 https://gitcode.com/vim-airline/vim-airline.git ${vim一配置路径}/start/VIM状态栏
|
||||
|
@ -176,6 +180,9 @@ readonly 系统一发行版一名称=$(echo "${NAME}")
|
|||
}
|
||||
|
||||
优化一常用命令(){
|
||||
# 优化git, 修复git中文显示为8进制风格的问题
|
||||
git config --global core.quotepath false
|
||||
|
||||
typeset -A 列表=(
|
||||
["vim"]="添加常用配置项(允许复制 添加行号 显式当前行等), 常用插件(目录 语法检测)"
|
||||
["ls"]="使用lsd替代老旧的ls, (lsd是rust编写的兼容ls的目录查看工具, 其丰富的配色和图标可有效增加目录的可读性)"
|
||||
|
|
76
文档/言灵vim使用说明.md
Normal file
76
文档/言灵vim使用说明.md
Normal file
|
@ -0,0 +1,76 @@
|
|||
# 寻觅的vim用法
|
||||
|
||||
言灵vim配置用法, 查看此教程前需对vim有一定了解, 如果您完全没有使用过vim, 请在命令行中执行 `vimtutor` 学习vim相关操作后再来查看此vim扩展
|
||||
> 最少查看 `vimtutor` 的前三章
|
||||
|
||||
|
||||
## 快捷键
|
||||
|
||||
vim常用快捷键记录
|
||||
|
||||
> 备注: <占位符>(\<leader>): 是vim中自定义的键盘前缀, 默认使用反斜杠`\`
|
||||
> 可以在`~/.vimrc`中自定义为其他键位`let mapleader = 'x'`
|
||||
> 冒号 `:` 开头的快捷键是需要用户在预览模式下输入启动
|
||||
|
||||
* `[数量]<占位符>cc` 注释当前行和选中行
|
||||
* `[数量]<占位符>ci` 执行反转注释操作,选中区域注释部分取消注释,非注释部分添加注释
|
||||
* `[数量]<占位符>cA` 跳转到该行结尾添加注释,并进入编辑模式
|
||||
* `[数量]<占位符>cu` 取消注释
|
||||
|
||||
* `ctrl ]` 跳转到光标下的函数定义处
|
||||
* `*` 在本文件中查找函数或变量
|
||||
* `ctrl o` 返回跳转之前的位置
|
||||
* `ctrl i` 返回 `ctrl o` 跳转之前的位置
|
||||
|
||||
* `ctrl n` 打开目录
|
||||
* `<占位符>n` 将光标聚焦到目录
|
||||
* `ctrl t` 切换目录状态(打开则关闭, 关闭则打开)
|
||||
* `ctrl f` 打开目录搜索框
|
||||
* `ctrl w` 多个窗口之间切换焦点, 按下此快捷键后在按上下左右或者k(上)j(下)h(左)l(右)
|
||||
* `:sp` 水平切分窗口
|
||||
* `:vsp` 垂直切分窗口
|
||||
* `ctrl 6` 切换缓冲区
|
||||
* `:bn` 切换到下一个缓冲区
|
||||
* `:bp` 切换到上一个缓冲区
|
||||
|
||||
* `<占位符>ff` 目录搜索(相当于:Leaderf file)
|
||||
* `<占位符>fb` 缓冲区搜索(相当于:Leaderf buffer)
|
||||
* `<占位符>fm` 搜索最近使用的文件(相当于:Leaderf mru)
|
||||
* `<占位符>ft` 在缓冲区中导航标签, 相当于搜索当前文件定义的函数(相当于:Leaderf bufTag)
|
||||
* `<占位符>fl` 在缓冲区中搜索行, 相当于搜索当前文件(相当于:Leaderf line)
|
||||
* `ctrl j` \[搜索窗口]向下移动搜索框
|
||||
* `ctrl k` \[搜索窗口]向上移动搜索框
|
||||
* `ctrl x` \[搜索窗口]在水平拆分窗口中打开
|
||||
* `ctrl ]` \[搜索窗口]在垂直拆分窗口中打开
|
||||
* `ctrl T` \[搜索窗口]在新选项卡页中打开
|
||||
* `ctrl ↓` \[搜索窗口]在弹出预览窗口中向下滚动
|
||||
* `ctrl ↑` \[搜索窗口]在弹出预览窗口中向上滚动
|
||||
* `ctrl R` \[搜索窗口]在模糊搜索模式和正则表达式模式之间切换
|
||||
* `ctrl F` \[搜索窗口]在全路径搜索模式和仅名称搜索模式之间切换
|
||||
* `ctrl B` 使用 Leaderf 插件和 rg 命令在当前缓冲区中进行模糊搜索当前光标下的单词
|
||||
* `ctrl F` 使用 Leaderf 插件和 rg 命令在所有文件中进行模糊搜索当前光标下的单词
|
||||
* `gf` 在可视模式下选择文本后,使用 Leaderf 插件和 rg 命令进行精确搜索所选的文本
|
||||
* `go` 执行上次搜索
|
||||
|
||||
## 代码补全工具(coc.nvim)
|
||||
|
||||
```vim
|
||||
# 安装
|
||||
:CocInstall [包名]
|
||||
# 更新
|
||||
:CocUpdate
|
||||
# 移除
|
||||
:CocUninstall [包名]
|
||||
# 查看已安装
|
||||
:CocList extensions
|
||||
```
|
||||
|
||||
## 已安装插件
|
||||
|
||||
* 代码补全工具(coc.nvim)
|
||||
* 数状目录(nerdtree)
|
||||
* VIM状态栏(`vim-airline/vim-airline`): https://gitcode.com/vim-airline/vim-airline/overview
|
||||
* 注释工具(`preservim/nerdcommenter`): https://gitcode.com/mirrors/preservim/nerdcommenter/overview
|
||||
* 模糊搜索(`Yggdroot/LeaderF`): https://gitcode.com/Yggdroot/LeaderF/overview
|
||||
|
||||
|
32
配置/vimrc
32
配置/vimrc
|
@ -29,10 +29,24 @@ let g:NERDCompactSexyComs = 1 " 使用紧凑的语法来美化多行
|
|||
let g:NERDTrimTrailingWhitespace = 1 " 启用在取消注释时修剪尾部空白的功能
|
||||
let g:NERDToggleCheckAllLines = 1 " 启用 NERDCommenterToggle 以检查所有选定行是否已注释
|
||||
|
||||
" 树状目录: 使用目录启动时自动启动侧栏
|
||||
" 树状目录(preservim/nerdtree): 在vim侧栏启动目录
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
" 使用目录启动时自动启动侧栏
|
||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
|
||||
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
|
||||
" 在没有文件参数的情况下启动
|
||||
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
|
||||
" 定义树状目录的快捷键
|
||||
nnoremap <leader>n :NERDTreeFocus<CR>
|
||||
nnoremap <C-n> :NERDTree<CR>
|
||||
nnoremap <C-t> :NERDTreeToggle<CR>
|
||||
nnoremap <C-f> :NERDTreeFind<CR>
|
||||
" 如果目录是最后一个窗口则自动退出vim
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||
" 防止缓冲区目录冲突
|
||||
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
|
||||
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
|
||||
let g:NERDTreeFileLines = 1 " 显示文件行
|
||||
|
||||
" 标签生成器(ludovicchabant/vim-gutentags): 在特定目录下自动调用ctags生成标签
|
||||
set statusline+=%{gutentags#statusline()} " 在状态行中打印字符串“tag”,当Gutengs在后台生成内容时
|
||||
|
@ -44,3 +58,19 @@ 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']
|
||||
|
||||
" 模糊搜索(Yggdroot/LeaderF)
|
||||
let g:Lf_HideHelp = 1 " 在正常模式下不显示帮助
|
||||
let g:Lf_UseCache = 0 " 不使用缓存, 避免更新文件后搜索异常
|
||||
let g:Lf_UseVersionControlTool = 1 " 使用版本控制工具(如Git)来获取文件的状态信息
|
||||
let g:Lf_IgnoreCurrentBufferName = 1 " 忽略当前的缓冲区名称
|
||||
let g:Lf_WindowPosition = 'popup' " 窗口模式
|
||||
let g:Lf_ShortcutF = "<leader>ff" " 打开LeaderF搜索界面
|
||||
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
|
||||
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
|
||||
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
|
||||
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
|
||||
noremap <C-B> :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR>
|
||||
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
|
||||
" 按字面意思搜索视觉选择的文本
|
||||
xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>
|
||||
noremap go :<C-U>Leaderf! rg --recall<CR>
|
||||
|
|
Loading…
Reference in New Issue
Block a user