vhxubo's blog
关于

VSCode + Neo Vim

最开始的时候接触到vim,学习了好长时间,改了键位等等,但是最后还是死在了对vim的配置上面。

后来在VSCode里面使用vim键位,用了一段时间之后,发现打开文件的速度也太慢了,就放弃了vim。

想着不如直接学好VSCode自带的快捷键好了,于是乎开始深入学习VSCode,参照极客学院的VSCode教程。

直到现在,换上了VSCode的Neo Vim插件Neo Vim - Visual Studio Marketplace,打开速度可以接受,操作方法在Insert模式下与VSCode相互兼容,是一个很不错的选择。

init.vim

updatetime: 2021年7月9日 path: C:\Users\vhxubo\AppData\Local\nvim\init.vim

" 配置插件
call plug#begin('~/AppData/Local/nvim/plugged')

Plug 'tpope/vim-surround'
Plug 'asvetliakov/vim-easymotion'
Plug 'vim-scripts/argtextobj.vim'

call plug#end()

" 配置输入法切换的能力
autocmd InsertLeave * :silent :!C:\\tools\\im-select.exe 1033 && C:\\tools\\im-select.exe 2052

" 公用剪贴板
set clipboard^=unnamed,unnamedplus

" 配置leader
let mapleader = "\<Space>"

" 取消双leader
" map <Leader> <Plug>(easymotion-prefix)

" 配置快速修复
nnoremap <Leader>. <Cmd>call VSCodeNotify('editor.action.quickFix')<CR>

" VSCode侧边栏
nnoremap <Leader>b <Cmd>call VSCodeNotify('workbench.action.toggleSidebarVisibility')<CR>

" 复制后高亮
augroup highlight_yank
    autocmd!
    au TextYankPost * silent! lua vim.highlight.on_yank()
augroup END

配置Ctrl+S保存文件并退出insert模式

  "macros": {
"saveAndEscapeNeovim": [
"workbench.action.files.save",
"vscode-neovim.escape"
]
}
  {
"key": "ctrl+s",
"command": "macros.saveAndEscapeNeovim",
"when": "editorTextFocus && neovim.mode == insert"
}

列选择

CTRL + V 列选择

替换一个文本(从寄存器里面读)

Vim 寄存器完全手册 | Harttle Land

y yaw
daw
"0p

取消搜索之后的高亮

在vim中取消搜索的高亮_What the Fuck-CSDN博客_vim取消搜索

:nohlsearch
:noh

配置语言切换能力

autocmd InsertLeave * :silent :!C:\\tools\\im-select.exe 1033 && C:\\tools\\im-select.exe 2052

配置剪贴板

Copy paste not working in neovim : neovim

set clipboard^=unnamed,unnamedplus

代码折叠方案

使用VSCode的折叠快捷键,配合gj gk替代jk防止展开 Ctrl + Shift + [ 折叠代码 Ctrl + Shift + ] 展开代码

配置vim-easymotion

" 配置leader为空格
let mapleader = "\<Space>"

" 取消双leader
map <Leader> <Plug>(easymotion-prefix)

<leader>-fw 寻找w <leader>-w 对文本增加字符跳转前缀

Default Mapping      | Details
---------------------|----------------------------------------------
<Leader>f{char}      | Find {char} to the right. See |f|.
<Leader>F{char}      | Find {char} to the left. See |F|.
<Leader>t{char}      | Till before the {char} to the right. See |t|.
<Leader>T{char}      | Till after the {char} to the left. See |T|.
<Leader>w            | Beginning of word forward. See |w|.
<Leader>W            | Beginning of WORD forward. See |W|.
<Leader>b            | Beginning of word backward. See |b|.
<Leader>B            | Beginning of WORD backward. See |B|.
<Leader>e            | End of word forward. See |e|.
<Leader>E            | End of WORD forward. See |E|.
<Leader>ge           | End of word backward. See |ge|.
<Leader>gE           | End of WORD backward. See |gE|.
<Leader>j            | Line downward. See |j|.
<Leader>k            | Line upward. See |k|.
<Leader>n            | Jump to latest "/" or "?" forward. See |n|.
<Leader>N            | Jump to latest "/" or "?" backward. See |N|.
<Leader>s            | Find(Search) {char} forward and backward.
                     | See |f| and |F|.

Neo Vim

The gu, gU, and ~ are case operators.

To lowercase, uppercase, or toggle-case:

- the whole line: guu, gUU, g~~
- a word: guw, gUw, g~w
- a word object: guiw, gUiw, g~iw
- the character under cursor: vu, vU, ~

image

插件

安装

在Windows下,nvim的配置文件在~/AppData/Local/nvim/init.vim下,默认不存在,需要自己创建

call plug#begin('~/AppData/Local/nvim/plugged')

Plug 'tpope/vim-surround'

call plug#end()

tpope/vim-surround

删除一个配对符号 (delete a surrounding) ds 更改一个配对符号 (change a surrounding) cs 增加一个配对符号 (yank a surrounding) ys 在新的行增加一个配对符号并进行缩进 yS 在整行增加一个配对符号 yss 在整行增加一个配对符号,配对符号单独成行并进行缩进 ySs Yss 在行选择中,S<div>

691e0c29gy1frp69jz0x6g20ic0ds779

参考