forked from anishathalye/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 140
/
ideavimrc
144 lines (130 loc) · 3.31 KB
/
ideavimrc
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
" 显示当前模式
set showmode
" 共享系统粘贴板
set clipboard+=unnamed
" 打开行号
set number
" 打开相对行号
" set relativenumber
" 设置命令历史记录条数
set history=2000
" 关闭兼容vi
set nocompatible
" 开启语法高亮功能
syntax enable
" 允许用指定语法高亮配色方案替换默认方案
syntax on
" 模式搜索实时预览,增量搜索
set incsearch
" 设置搜索高亮 set hlsearch
" 忽略大小写 (该命令配合smartcase使用较好,否则不要开启)
set ignorecase
" 模式查找时智能忽略大小写
set smartcase
" vim自身命令行模式智能补全
set wildmenu
" 总是显示状态栏
set laststatus=2
" 显示光标当前位置
set ruler
" 高亮显示当前行/列
set cursorline
"set cursorcolumn
" 禁止折行
set nowrap
" 将制表符扩展为空格
set expandtab
" 设置编辑时制表符占用空格数
set tabstop=8
" 设置格式化时制表符占用空格数
set shiftwidth=4
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4
" 基于缩进或语法进行代码折叠
set foldmethod=indent
set foldmethod=syntax
" 启动 vim 时关闭折叠代码
set nofoldenable
" 设置前导键
let mapleader=";"
" 暂时取消搜索高亮快捷键
nnoremap <silent> <Leader>l :<C-u>nohlsearch<CR><C-l>
" 移动相关
" 前一个缓冲区
nnoremap <silent> [b :w<CR>:bprevious<CR>
" 后一个缓冲区
nnoremap <silent> ]b :w<CR>:bnext<CR>
" 定义快捷键到行首和行尾
map H ^
map L $
" 定义快速跳转
nmap <Leader>t <C-]>
" 定义快速跳转回退
nmap <Leader>T <C-t>
" 标签页后退 ---标签页前进是gt
nmap R gt
nmap E gT
" 文件操作相关
" 定义快捷键关闭当前分割窗口
nmap <Leader>q :q<CR>
" 定义快捷键保存当前窗口内容
nmap <Leader>w :w<CR>
" 窗口操作相关
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Focus center or current cursor position after \"J\"
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ`z
" nnoremap j jzz
" nnoremap k kzz
" Moving text
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" 使用idea内部功能
" copy operation
nnoremap <Leader>c :action $Copy<CR>
" paste operation
nnoremap <Leader>v :action $Paste<CR>
" cut operation
nnoremap <Leader>x :action $Cut<CR>
" Select All
nnoremap <Leader>a :action $SelectAll<CR>
" reformat code
nnoremap <Leader>f :action ReformatCode<CR>
" New File
nnoremap <Leader>n :action NewFile<CR>
" go to class
nnoremap <Leader>gc :action GotoClass<CR>
" go to action
nnoremap <Leader>ga :action GotoAction<CR>
" run SaveAll + Run
nnoremap <Leader>r :action SaveAll<CR>:action RunClass<CR>
" 显示当前文件的文件路径
nnoremap <Leader>fp :action ShowFilePath<CR>
" 隐藏激活窗口
nnoremap <Leader>h :action HideActiveWindow<CR>
" 查看函数调用链
nnoremap <Leader>in :action CallHierarchy<CR>
nnoremap <Leader>s :action SendLocation<CR>
" 查询文件
nnoremap <Space>f :action GotoFile<CR>
" 查询Symbol
nnoremap <Space>S :action GotoSymbol<CR>
" 找到usage
nnoremap <Leader>u :action FindUsages<CR>
" 中英文自动切换
set keep-english-in-normal
" other vim plugins
" comment plugin
set commentary
" surround plugin
set surround
" easymotion
set easymotion
" some useful shortcuts in ide, but doesn't remap those.
" open project file tree ---------- alt + 1
" open terminal window ---------- alt + F12
set ideajoin