日常生活的交流与学习

首页 新随笔 联系 管理

自己的配置

" ================================================================================================
" = Extensions =====================================
" ================================================================================================
Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree'

" ================================================================================================
" = Basic settings =====================================
" ================================================================================================
set clipboard+=unnamed
set ignorecase
set scrolloff=30
set history=200

set number
set relativenumber

set incsearch
set hlsearch
set keep-english-in-normal

" ================================================================================================
" = No Leader Keymaps =====================================
" ================================================================================================
" 设置 jk 映射为 esc键
inoremap jk <ESC>

nmap ge <action>(GotoNextError)
nmap gm <action>(MethodUp)
nmap gi <action>(GotoImplementation)
" last changed in current buffer(file)
nmap ga '.



"快速切换到又字符位置的行首和行尾巴"
nmap L g_
nmap H ^
vmap L g_
vmap H ^;






" ================================================================================================
" = Leader Keymaps =====================================
" ================================================================================================
" leaderkey
let mapleader=" "

" ================================================================================================
" 👻👻👻 Which-Key 👻👻👻
" ================================================================================================
set which-key
set notimeout

"切换tab页"
nmap <leader>p <action>(PreviousTab)



" f: Find/Format---------------------------------------
let g:WhichKeyDesc_FindOrFormat = "<leader>f FindOrFormat"
let g:WhichKeyDesc_FindOrFormat_FindFile = "<leader>ff FindFile"
nmap <leader>ff <action>(GotoFile)

let g:WhichKeyDesc_FindOrFormat_FindFileLocation = "<leader>fl FindFileLocation"
nmap <leader>fl <action>(SelectInProjectView)

let g:WhichKeyDesc_FindOrFormat_FindText = "<leader>ft FindText"
nmap <leader>ft <action>(FindInPath)

let g:WhichKeyDesc_FindOrFormat_Commands = "<leader>fc Commands"
nmap <leader>fc <action>(GotoAction)

let g:WhichKeyDesc_FindOrFormat_OpenedProject = "<leader>fp OpenedProject"
nmap <leader>fp <action>(OpenProjectWindows)

let g:WhichKeyDesc_FindOrFormat_Format = "<leader>fm Format"
nmap <leader>fm <action>(ReformatCode) \| <action>(OptimizeImports)
"---------------------------------------------------------------------"




" g: GotoDeclation"----------------------------------------
let g:WhichKeyDesc_Goto = "<leader>g Goto"
let g:WhichKeyDesc_Goto_GotoDeclation = "<leader>gd GotoDeclation"
nmap <leader>gd <action>(GotoDeclation)

" h: HideActiveWindow-------------------------------------
let g:WhichKeyDesc_Hide= "<leader>h Hide"
let g:WhichKeyDesc_Hide_ActiveWindow= "<leader>hw HideActiveWindow"
nmap <leader>hw <action>(HideActiveWindow)
let g:WhichKeyDesc_Hide_Explorer= "<leader>he HideExplorer"
nmap <leader>he <action>(HideSideWindows)
"------------------------------------------------------------------"



" i: Insert 这个功能还是挺实用的---------------------------------------
let g:WhichKeyDesc_InsertAfterBrackets = "<leader>i InsertAfterBrackets"
nmap <leader>i f(a
"-------------------------------------------------------------------"





" j: add Semicolon and goto nextline--------------------------------
" let g:WhichKeyDesc_InsertSemicolon = "<leader>j InsertSemicolon"
" nmap <leader>j A;<ESC>o
"-------------------------------------------------------------------"




" n: NextTab,NewFile,NewFile ------------------------------------------
let g:WhichKeyDesc_NextOrNew = "<leader>n NextOrNew"
let g:WhichKeyDesc_NextOrNew_NextTab = "<leader>nt NextTab"
nmap <leader>nt <action>(NextTab)
let g:WhichKeyDesc_NextOrNew_NewFile = "<leader>nf NewFile"
nmap <leader>nf <action>(NewFile)
let g:WhichKeyDesc_NextOrNew_NewDir = "<leader>nd NewDir"
nmap <leader>nd <action>(NewDir)
"----------------------------------------------------------------------


" s: Show---------------------------------------------------
let g:WhichKeyDesc_Show = "<leader>s Show"
let g:WhichKeyDesc_Show_FileStructure = "<leader>ss ShowFileStructure"
nmap <leader>ss <action>(FileStructurePopup)
let g:WhichKeyDesc_Show_Bookmarks = "<leader>sb ShowBookmarks"
nmap <leader>sb <action>(ShowBookmarks)
let g:WhichKeyDesc_Show_ParameterInfo = "<leader>sb ShowParameterInfo"
nmap <leader>sp <action>(ParameterInfo)
let g:WhichKeyDesc_Show_Hover = "<leader>sh ShowHover"
nmap <leader>sh <action>(Documentation.ToggleShowInPopup)
"------------------------------------------------------------"



" r: rerun rename reruntest -------------------------------------------
let g:WhichKeyDesc_RunOrRe = "<leader>r RunOrRe"
let g:WhichKeyDesc_RunOrRe_RunClass = "<leader>rc RunClass"
nmap <leader>rc <action>(RunClass)
let g:WhichKeyDesc_RunOrRe_ReRun = "<leader>rr ReRun"
nmap <leader>rr <action>(Rerun)
let g:WhichKeyDesc_RunOrRe_ReRunTests = "<leader>rt ReRunTests"
nmap <leader>rt <action>(RerunTests)
"--------------------------------------------------------------------"

" r: rerun rename reruntest -------------------------------------------
let g:WhichKeyDesc_RunOrRe = "<leader>r RunOrRe"
let g:WhichKeyDesc_RunOrRe_RunClass = "<leader>rc RunClass"
nmap <leader>rc <action>(RunClass)
let g:WhichKeyDesc_RunOrRe_ReRun = "<leader>rr ReRun"
nmap <leader>rr <action>(Rerun)
let g:WhichKeyDesc_RunOrRe_ReRunTests = "<leader>rt ReRunTests"
nmap <leader>rt <action>(RerunTests)
let g:WhichKeyDesc_RunOrRe_Rename = "<leader>rn Rename"
map <leader>rn <action>(RenameElement)
"----------------------------------------------------------------------


" w: Window
let g:WhichKeyDesc_Windows = "<leader>w Windows"
let g:WhichKeyDesc_Windows_maximize = "<leader>wo maximize"
nmap <leader>wo <action>(UnsplitAll) \| <action>(HideAllWindows)
let g:WhichKeyDesc_Windows_splitWindowVertically = "<leader>wl splitWindowVertically"
nmap <leader>wl <action>(Macro.SplitVertically)
let g:WhichKeyDesc_Windows_closeActiveWindow = "<leader>wc closeActiveWindow"
nmap <leader>wc <c-w>c



" z: zip(fold)
let g:WhichKeyDesc_Zip = "<leader>z Zip"
let g:WhichKeyDesc_Zip_unZipAll = "<leader>zo unZipAll"
nmap <leader>zo <action>(ExpandAllRegions)
let g:WhichKeyDesc_Zip_ZipAll = "<leader>zc ZipAll"
nmap <leader>zc <action>(CollapseAllRegions)


" c: Close ⭐️;
"let g:WhichKeyDesc_CloseBuffer = "<leader>c CloseBuffer"
"nmap <leader>c :q!<CR>






" e: Toggle Explorer------------------------------------------
let g:WhichKeyDesc_ToggleExplorerOrExtract = "<leader>e ToggleExplorerOrExtract"
let g:WhichKeyDesc_ToggleExplorerOrExtract_ToggleExplorer = "<leader>ep ToggleExplorer"
nmap <leader>ep <action>(ActivateProjectToolWindow)
" e: Extract
" extract method/function
let g:WhichKeyDesc_ToggleExplorerOrExtract_ExtractMethod = "<leader>em ExtractMethod"
vmap <leader>em <action>(ExtractMethod)
" extract constant
let g:WhichKeyDesc_ToggleExplorerOrExtract_IntroduceConstant = "<leader>ec IntroduceConstant"
vmap <leader>ec <action>(IntroduceConstant)
" extract field
let g:WhichKeyDesc_ToggleExplorerOrExtract_IntroduceField = "<leader>ef IntroduceField"
vmap <leader>ef <action>(IntroduceField)
" extract variable
let g:WhichKeyDesc_ToggleExplorerOrExtract_IntroduceVariable = "<leader>ev IntroduceVariable"
vmap <leader>ev <action>(IntroduceVariable)
"---------------------------------------------------------------------------------------------"

网上参考配置

inoremap jk <ESC>
set clipboard+=unnamed  "共享剪切板
syntax on  "语法高亮
" set number relativenumber "显示行号(由于Idea中有行号显示,则vim中的显示行号就不配置了)
set ruler  "显示光标所在位置的行号和列号
set wrap   "自动折行
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab     "将tab替换为相应数量空格
set smartindent
set backspace=2
set co=5
set nobackup "设置取消备份 禁止临时文件生成
set noswapfile
set keep-english-in-normal " 为IdeaVim插件增加自动切换为英文输入法的功能,idea 需要安装 IdeaVimExtension plugin
set showmatch "设置匹配模式 类似当输入一个左括号时会匹配相应的那个右括号
set clipboard^=unnamed,unnamedplus
"set laststatus=2   "命令行为两行
set fenc=utf-8     "文件编码
"set mouse=a        "启用鼠标
"set ignorecase     "忽略大小写
set cursorline     "突出显示当前行
"set cursorcolumn   "突出显示当前列
set fdm=marker
posted on 2022-10-09 20:34  lazycookie  阅读(54)  评论(0编辑  收藏  举报