目錄
  1. 1. 基础用法
    1. 1.1. 插入
    2. 1.2. 移动
    3. 1.3. 搜索
    4. 1.4. 替换
    5. 1.5. 补全
    6. 1.6. 复制粘贴
    7. 1.7. 分屏
    8. 1.8. 选择
    9. 1.9. 删除
  2. 2. 插件
    1. 2.1. 插件管理器
    2. 2.2. 注释
    3. 2.3. 对称
  3. 3. 主题
  4. 4. 配置文件
my_vim

男人嘛,就要华而不实,花里胡哨!

基础用法

插入

1
2
3
i  insert
a append
o 换行

移动

1
2
3
4
5
h/j/k/l  左/下/上/右
w/e 单词
gg/G 文件首/文件尾
0/$ 行首/行尾
ctrl+f/ctrl+u 向前翻页/向后翻页

搜索

1
2
3
4
/{char}     搜索字符串
set hlsearch 高亮
noh 取消高亮
n/N 下一个/上一个

替换

1
2
% s/s1/s2/g      全局替换
2,10 s/s1/s2/c 显示匹配个数

补全

1
2
3
c+n c+p  单词
c+x c+f 文件名
c+x c+o 代码

复制粘贴

1
2
3
y/p   复制/粘贴
set parst 粘贴模式
set noparst 取消粘贴模式

分屏

1
2
vs  竖分屏(vertical split)
sp 横分屏(split)

选择

1
2
3
v  字符
V 行选
c+v 块选

删除

1
2
3
d    删除
dw 删除单词
dd 删除行

插件

插件管理器

vim-plug

1
2
3
#unix 安装方法
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

注释

vim-commentary

1
2
gcc  注释/取消注释
cc 删除一行并进入insert模式

对称

vim-surround

1
2
3
4
5
6
ds   删除
cs 替换
ys 添加

ys iw " 单词添加
ys iW " 字符串添加(空格分隔)

主题

配置文件

~/.vimrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
set nu
"colorscheme molokai
colorscheme skeletor
set tabstop=4
set hlsearch
set foldmethod=indent
set autoindent
let mapleader=','
inoremap <leader>w <Esc>:w<cr>
nnoremap <leader>w :w<cr>
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
Plug 'mhinz/vim-startify'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Yggdroot/indentLine'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-commentary'
call plug#end()

" NERDTree
nnoremap <leader>v :NERDTreeFind<cr>
nnoremap <leader>n :NERDTreeToggle<cr>
let NERDTreeShowHidden=1

" ctrlp.vim
let g:ctrlp_map='<c-p>'

" pymode
let g:pymode_python = 'python3'
let g:pymode_trim_whitespaces = 1
let g:pymode_doc = 1
let g:pymode_docbind = 'K'
let g:pymode_rope_goto_definition_bind = "<C-]>"
let g:pymode_lint = 1
let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe', 'pylint']
let g:pymode_options_max_line_length = 120

" easymotion
nmap ss <Plug>(easymotion-s2)
文章作者: kangel
文章鏈接: https://j-kangel.github.io/2019/12/19/my-vim/
版權聲明: 本博客所有文章除特別聲明外,均採用 CC BY-NC-SA 4.0 許可協議。轉載請註明來自 KANGEL