• 欢迎光临~

vscode 和 pycharm的vim配置

开发技术 开发技术 2022-10-21 次浏览

settings.json

    // -------------------------------------------------
    "vim.leader": "<space>",
    "vim.useSystemClipboard": true,
    "vim.hlsearch": true,
    "vim.highlightedyank.enable": true,
    "vim.foldfix": true,
    "vim.easymotion": true,
    "vim.incsearch": true,
    "vim.useCtrlKeys": true,
    "vim.surround": true,
    "vim.sneak": true,
    "vim.sneakUseIgnorecaseAndSmartcase": true,
    "vim.normalModeKeyBindingsNonRecursive": [
        // Go to start or end of line---------------------------
        {
            "before": [
                "H"
            ],
            "after": [
                "^"
            ]
        },
        {
            "before": [
                "L"
            ],
            "after": [
                "$"
            ]
        },
        // ----------------------------------------------------
        // Jump to change
        {
            "before": [
                "[",
                "c",
            ],
            "commands": [
                "workbench.action.editor.previousChange"
            ]
        },
        {
            "before": [
                "]",
                "c"
            ],
            "commands": [
                "workbench.action.editor.nextChange"
            ]
        },
        // Code actions
        {
            "before": [
                "<leader>",
                "s",
                "a"
            ],
            "commands": [
                "editor.action.sourceAction"
            ]
        },
        {
            "before": [
                "<space>",
                "r",
                "r",
            ],
            "commands": [
                // "extension.runScript"
                // "autojspro.run"
                "code-runner.run"
            ]
        },
        // Quick fix
        {
            "before": [
                "<leader>",
                "q",
                "f"
            ],
            "commands": [
                "editor.action.quickFix"
            ]
        },
        // 重用名变量
        {
            "before": [
                "<leader>",
                "r",
                "n"
            ],
            "commands": [
                "editor.action.rename"
            ]
        },
        // Format 格式化当前文件
        {
            "before": [
                "<leader>",
                "f",
                "m"
            ],
            "commands": [
                "editor.action.formatDocument"
            ]
        },
        // go===================================================
        // go to  References
        {
            "before": [
                "g",
                "r"
            ],
            "commands": [
                "editor.action.goToReferences"
            ]
        },
        // ===================================================
        // new===================================================
        // 新建文件夹,在编辑器的区域
        {
            "before": [
                "<Leader>",
                "n",
                "d"
            ],
            "commands": [
                "explorer.newFolder"
            ]
        },
        // 新建文件,新建文件的位置取决于,文件资源管理器所在的位置
        {
            "before": [
                "<Leader>",
                "n",
                "f"
            ],
            "commands": [
                "explorer.newFile"
            ]
        },
        // =====================================================
        // open========================================================
        // 打开文件资源管理器,光标会聚焦到文件资源管理器的窗口
        {
            "before": [
                "<leader>",
                "o",
                "e"
            ],
            "commands": [
                "workbench.view.explorer"
            ]
        },
        // open search bar
        {
            "before": [
                "<leader>",
                "o",
                "s"
            ],
            "commands": [
                "workbench.action.quickOpen"
            ]
        },
        // 进入到terminal
        {
            "before": [
                "<leader>",
                "o",
                "t"
            ],
            "commands": [
                "workbench.action.terminal.toggleTerminal"
            ]
        },
        // 新建一个terminal终端
        {
            "before": [
                "<leader>",
                "o",
                "T"
            ],
            "commands": [
                "workbench.action.terminal.new"
            ]
        },
        // 隐藏和打开terminal
        {
            "before": [
                "<leader>",
                "o",
                "t"
            ],
            "commands": [
                "workbench.action.togglePanel"
            ]
        },
        // ================================================
        // find char in all files(fing in all files)
        {
            "before": [
                "<leader>",
                "f",
                "a"
            ],
            "commands": [
                "workbench.action.findInFiles"
            ]
        },
        // ===============================================
        // 移动==============================================================================
        // 左右移动标签页------------------------------------------------
        {
            "before": [
                "<leader>",
                "h"
            ],
            "commands": [
                "workbench.action.navigateLeft"
            ]
        },
        {
            "before": [
                "<leader>",
                "l"
            ],
            "commands": [
                "workbench.action.navigateRight"
            ]
        },
        // 移动下一个编辑器标签
        {
            "before": [
                "J"
            ],
            "commands": [
                "workbench.action.nextEditor"
            ]
        },
        // 移动到上一个编辑器标签
        {
            "before": [
                "K",
            ],
            "commands": [
                "workbench.action.previousEditor"
            ]
        },
        // 左右移动标签页---------------------------------------------------------------
        {
            "before": [
                "<space>",
                "'"
            ],
            "commands": [
                "workbench.action.maximizeEditor"
            ]
        },
        // 保存当前文件---------------------------------------------------------------
        {
            "before": [
                "<space>",
                "s"
            ],
            "commands": [
                "workbench.action.files.save"
            ]
        },
        {
            "before": [
                "g",
                "b"
            ],
            "commands": ["workbench.action.navigateBack"],
            "when": "canNavigateBack"
        },
        // workbench.action.closeActiveEditor
        {
            "before": [
                "<space>",
                "c",
                "c"
            ],
            "commands": [
                "workbench.action.closeActiveEditor"
            ]
        }
    ],
    "vim.insertModeKeyBindings": [
        // 退出插入模式
        {
            "before": [
                "j",
                "k"
            ],
            "after": [
                "<Esc>"
            ]
        }
    ],
    "vim.visualModeKeyBindingsNonRecursive": [
        // 移动到非空字符的行首
        {
            "before": [
                "H"
            ],
            "after": [
                "^"
            ]
        },
        // 移动到非空字符的行尾
        {
            "before": [
                "L"
            ],
            "after": [
                "$"
            ]
        },
    ],
    "vim.digraphs": {},
    "vim.commandLineModeKeyBindings": [],
    "vim.commandLineModeKeyBindingsNonRecursive": [],

keybinds.json

// Place your key bindings in this file to override the defaultsauto[]
[
    // 以前配置的上下左右移动按键
    {
        "key": "alt+j",
        "command": "cursorLeft",
        "when": "textInputFocus"
    },
    {
        "key": "alt+k",
        "command": "cursorDown",
        "when": "textInputFocus"
    },
    {
        "key": "alt+l",
        "command": "cursorRight",
        "when": "textInputFocus"
    },
    {
        "key": "alt+i",
        "command": "cursorUp",
        "when": "textInputFocus"
    },
    // 切换到文件浏览器,可以在任何位置
    {
        "key": "ctrl+;",
        "command": "workbench.view.explorer",
        "when": "viewContainer.workbench.view.explorer.enabled"
    },
    // 切换到代码编辑区,不论在任何位置
    {
        "key": "ctrl+'",
        "command": "workbench.action.focusFirstEditorGroup"
    },
    // 切换到terminal终端
    {
        "key": "ctrl+,",
        "command": "workbench.action.terminal.toggleTerminal",
        "when": "terminal.active"
    },
    // 打开一个新的terminal
    {
        "key": "ctrl+shift+,",
        "command": "workbench.action.terminal.new",
        "when": "terminalProcessSupported || terminalWebExtensionContributedProfile"
    },
    // 在文件夹资源管理器中新建一个文件
    {
        "key": "a",
        "command": "explorer.newFile",
        "when": "filesExplorerFocus && !inputFocus"
    },
    // 在文件资源管理器里面创建一个文件夹
    {
        "key": "shift+a",
        "command": "explorer.newFolder",
        "when": "filesExplorerFocus && !inputFocus"
    },
    // 在文件资源管理器里面重应名当前文件或文件夹
    {
        "key": "r",
        "command": "renameFile",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
    },
    // 在文件资源管理器中删除文件
    {
        "key": "d",
        "command": "deleteFile",
        "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
    },
    // 放大editor区域
    {
        "key": "ctrl+m",
        "command": "workbench.action.maximizeEditor"
    },
    // 使用code runner运行代码
    {
        "key": "ctrl+r",
        "command": "code-runner.run"
    }
]

pycharm vim

" ================================================================================================
" = 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

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

nmap ge <action>(GotoNextError)
nmap gE <action>(GotoPreviousError)

nmap gm <action>(MethodUp)
nmap gM <action>(MethodDown)

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


"快速切换tab页,这个我是模仿vimchrome的快捷键"
nmap J <action>(NextTab)
nmap K <action>(PreviousTab)
vmap J <action>(NextTab)
vmap K <action>(PreviousTab)

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






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

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



" 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)

let g:WhichKeyDesc_FindOrFormat_FindUsages = "<leader>fu FindUsages"
nmap <leader>fu <action>(FindUsages)
"---------------------------------------------------------------------"


" g: GotoDeclation"----------------------------------------
let g:WhichKeyDesc_Goto = "<leader>g Goto"
let g:WhichKeyDesc_Goto_GotoDeclation = "<leader>gd GotoDeclation"
nmap <leader>gd <action>(GotoDeclaration)
let g:WhichKeyDesc_Goto_GotoBack = "<leader>gb GotoBack"
nmap <leader>gb <action>(Back)

" 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: NewFile,NewFile ------------------------------------------
let g:WhichKeyDesc_New = "<leader>n New"
let g:WhichKeyDesc_New_NewFile = "<leader>nf NewFile"
nmap <leader>nf <action>(NewFile)
let g:WhichKeyDesc_New_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)
"ShowErrorDescription
let g:WhichKeyDesc_Show_ShowError = "<leader>se ShowErrorDescription"
nmap <leader>se <action>(ShowErrorDescription)
"------------------------------------------------------------"



" 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>wr splitWindowVertically"
nmap <leader>wl <action>(MoveTabRight)
let g:WhichKeyDesc_Windows_CloseAllEditorsButActive = "<leader>wa CloseAllEditorsButActive"
nmap <leader>wa <action>(CloseAllEditorsButActive)
let g:WhichKeyDesc_Windows_CloseEditor = "<leader>wc CloseEditor"
nmap <leader>wc <action>(CloseEditor)

" 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)
"空格+;,快速打开文件资源浏览器"
nmap <leader>; <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)
"---------------------------------------------------------------------------------------------"


程序员灯塔
转载请注明原文链接:vscode 和 pycharm的vim配置
喜欢 (0)