Vim相关配置

记录一下有关vim的一些设置,以免电脑寄了不好重新配置

vscode+vim

首先是vscode中的vim模式

在应用商店中搜索vim插件安装即可

然后在setting中添加以下有关vim 的配置

js 复制代码
    "vim.easymotion": true,
    "vim.surround": true,
    "vim.incsearch": true,
    "vim.useSystemClipboard": true,
    "editor.lineNumbers": "relative",
    "vim.useCtrlKeys": true,
    "vim.hlsearch": true,
    "vim.smartRelativeLine": false,
    "editor.cursorBlinking": "smooth",
    "editor.cursorSmoothCaretAnimation": "on",
    "vim.insertModeKeyBindings": [
        {
        "before": ["j", "j"],
        "after": ["<Esc>"]
        }
    ],
    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before":[
                "leader",
                "e"
            ],
            "commands": [
                {
                "command": "workbench.action.toggleSidebarVisibility"
                }
            ]
        },
        {
        "before": ["<C-j>"],
        "after": ["4","j"]
        },
        {
        "before": ["<C-k>"],
        "after": ["4","k"]
        },
        {
        "before": ["<C-d>"],
        "after": ["9","j"]
        },
        {
        "before": ["<C-u>"],
        "after": ["9","k"]
        },
        {

        "before": ["<C-n>"],
        "commands": [":nohl"]
        },
        {
        "before": ["K"],
        "commands": ["lineBreakInsert"],
        "silent": true
        },
        {
        "before": ["<C-p>"],
        "commands": ["extension.fuzzySearch"],
        },
        {
            "before": [
                "H"
            ],
            "after": [
                "^"            
            ]
        },
        {
            "before": [
                "L"
            ],
            "after": [
                "$"            
            ]
        }
    ],
    "vim.visualModeKeyBindings": [
        {
        "before": [
            ">"
        ],
        "commands": [
            "editor.action.indentLines"
        ]
        },
        {
        "before": [
            "<"
        ],
        "commands": [
            "editor.action.outdentLines"
        ]
        },
        {
            "before": [
                "H"
            ],
            "after": [
                "^"            
            ]
        },
        {
            "before": [
                "L"
            ],
            "after": [
                "$"            
            ]
        }
    ],
    "vim.leader": "<space>",
    "vim.handleKeys": {
        "<C-a>": false,
        "<C-f>": false
    },

    "extensions.experimental.affinity": {
        "vscodevim.vim": 1
    },

然后是一些更加定制的东西,需要用到当前的不同状态,因此在keybindings.json中添加以下内容

js 复制代码
[
  {
    "key": "ctrl+left",
    "command": "workbench.action.increaseViewWidth",
    "when": "vim.mode == 'Normal'"
  },

  {
    "key": "ctrl+right",
    "command": "workbench.action.decreaseViewWidth",
    "when": "vim.mode == 'Normal'"
  },

  {
    "key": "ctrl+up",
    "command": "workbench.action.increaseViewHeight",
    "when": "vim.mode == 'Normal'"
  },

  {
    "key": "ctrl+down",
    "command": "workbench.action.decreaseViewHeight",
    "when": "vim.mode == 'Normal'"
  },
  // 以下是 vim 绑定的键位
  
  {
    "key": "alt+j",
    "command": "selectNextSuggestion",
    "when": "vim.active && suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "alt+k",
    "command": "selectPrevSuggestion",
    "when": "vim.active && suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  // 在 quickOpen 的对话框中上下跳转
  {
    "key": "ctrl+j",
    "command": "workbench.action.quickOpenSelectNext",
    "when": "vim.active && inQuickOpen"
  },
  {
    "key": "ctrl+k",
    "command": "workbench.action.quickOpenSelectPrevious",
    "when": "vim.active && inQuickOpen"
  },
  // 当光标聚焦在编辑器中且 vim 处于 normal 模式时,进行 tab 栏目的左右跳转
  {
    "key": "alt+h",
    "command": "workbench.action.previousEditor",
    "when": "editorTextFocus && vim.mode == 'Normal'"
  },
  {
    "key": "alt+l",
    "command": "workbench.action.nextEditor",
    "when": "editorTextFocus && vim.mode == 'Normal'"
  },
  // vim 模式下的左侧的文件管理器的操作
  // 在文件管理器中搜索
  {
    "key": "/",
    "command": "list.find",
    "when": "listFocus && listSupportsFind && !inputFocus"
  },
  // 新建一个文件
  {
    "key": "a",
    "command": "explorer.newFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },
  // 新建一个文件夹
  {
    "key": "shift+a",
    "command": "explorer.newFolder",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },

  // 给文件重命名
  {
    "key": "r",
    "command": "renameFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },
  // 删除文件
  {
    "key": "d",
    "command": "deleteFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },
  // 调整底部的 panel 的大小
  {
    "key": "ctrl+shift+k",
    "command": "workbench.action.terminal.resizePaneUp",
    "when": "terminalFocus"
  },
  {
    "key": "ctrl+shift+j",
    "command": "workbench.action.terminal.resizePaneDown",
    "when": "terminalFocus"
  },
  // 最大化 terminal
  {
    "key": "ctrl+win+`",
    "command": "workbench.action.toggleMaximizedPanel",
    "when": "terminalFocus"
  },
  {
    "key": "ctrl+w",
    "command": "-workbench.action.closeActiveEditor"
  }
]

浏览器+vim

下载Vimium C插件,实现全键盘操作浏览器

主要就改了两个快捷键,让ctrl+j/k 快速上下翻动

js 复制代码
map <c-j> scrollDown count=3
map <c-k> scrollUp count=3

将默认搜索引擎变为bing

js 复制代码
https://cn.bing.com/search?q=$s

UI选的是下面这个配置

css 复制代码
/* #ui */
* {
/*insertroot*/
  --font-size: 17px;
  --font-size-link: 12px;
  --font-weight: normal;
  --font: Source Code Pro, sans;
  --padding: 0px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);

  /* ----------  DAY THEME  ---------- */
  --bg: #282c34;
  --fg: #969ca8;
  --accent-fg: #2e323c;
  --border: #000000;
  --title: #969ca8;
  --title-accent: #4892c6;
  --link: #6b7176;
  --link-accent: #d7ae74;
  
  /* ---------- NIGHT THEME ---------- */
  --nbg: #282c34;
  --nfg: #969ca8;
  --naccent-fg: #2e323c;
  --nborder: #000000;
  --ntitle: #969ca8;
  --ntitle-accent: #4892c6;
  --nlink: #6b7176;
  --nlink-accent: #d7ae74;
  

  font-family: var(--font);
  font-size: var(--font-size-link);
}

/* HUD */
.HUD {
  border-radius: 3px;
  text-transform: lowercase;
  color: var(--title);
  max-width: 420px;
  min-width: unset;
  line-height: 20px;
  align-items: center;
  padding: 10px;
}

.HUD.D {
  color: var(--ntitle);
}

.HUD:after {
  background: var(--bg);
  border: var(--border);
}

.HUD.D:after {
  background: var(--nbg);
  border: var(--nborder);
}

.HUD.UI {
  min-width: 380px;
  align-items: unset;
}

/* HINTS */
.LH {
  color: var(--fg);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.D .LH {
  color: var(--nfg);
  border: 1px solid var(--nborder);
  background: var(--nbg);
  box-shadow: var(--shadow);
}

.MC {
  color: var(--accent-fg);
}

.D .MC {
  color: var(--naccent-fg);
}


/* #omni */
* {
/*insertroot*/
  --font-size: 17px;
  --font-size-link: 12px;
  --font-weight: normal;
  --font: Source Code Pro, sans;
  --padding: 0px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);

  /* ----------  DAY THEME  ---------- */
  --bg: #282c34;
  --fg: #969ca8;
  --accent-fg: #2e323c;
  --border: #000000;
  --title: #969ca8;
  --title-accent: #4892c6;
  --link: #6b7176;
  --link-accent: #d7ae74;
  
  /* ---------- NIGHT THEME ---------- */
  --nbg: #282c34;
  --nfg: #969ca8;
  --naccent-fg: #2e323c;
  --nborder: #000000;
  --ntitle: #969ca8;
  --ntitle-accent: #4892c6;
  --nlink: #6b7176;
  --nlink-accent: #d7ae74;


  font-family: var(--font);
  /*font-size: var(--font-size);*/
}

body {
  animation: show 200ms cubic-bezier(0, 0, 0.2, 1) forwards;
  box-shadow: var(--shadow);
}

body.has-dark{

}

/* Animate Slide in */
@keyframes show {
  0% {
    opacity: 0;
    transform: translateY(50px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

#toolbar {
  top: 10px;
  right: 14px;
  opacity: 0;
}

#toolbar:hover {
  opacity: 1;
}

#bar, #input, #list {
  background: var(--bg);
  font-weight: var(--font-weight);
}
.has-dark #bar, .has-dark #input, .has-dark #list {
  background: var(--nbg);
}

#bar{
  padding: 10px;
/*padding: var(--padding);*/
  border-bottom: none;
}

#bar::before{
/*for hint or content icon before typing*/
  content: "➤";
  position: absolute;
  left: 20px;
  z-index: 300;
  padding: 6px 0;
  font-weight: bold;
  font-size: var(--font-size);
  color: var(--fg);
}

.has-dark #bar::before{
  color: var(--nfg);
}

#input {
  padding: var(--padding) 38px;
  color: var(--title);
  border: none;
  box-shadow: none;
}

.has-dark #input {
  color: var(--ntitle);
}

.item .icon {
  width: 24px;
  height: 24px;
  padding-right: unset;
  margin-right: 10px;
  margin-top: 5px;
  background-position: bottom right;
}

.item .icon path {
  opacity: 0.25;
  position: absolute;
  z-index: -1;
  transform-origin: 0px 0px;
  transform: scale(0.75);
}

.item.s,
.item:hover {
  background-color: var(--accent-fg);
  border: 3px rgba(0, 0, 0, 0.02) solid;
  cursor: pointer;
}

.has-dark .item.s,
.has-dark .item:hover {
  background-color: var(--naccent-fg);
}

.item .top {
  color: var(--title);
  position: relative;
  height: 30px;
}

.has-dark .item .top {
  color: var(--ntitle);
}

.item .top .title {
  font-size: var(--font-size);
  line-height: 10px;
  margin-top: 2px;
}

.item .top .title match {
  color: var(--title-accent);
}

.has-dark .item .top .title match {
  color: var(--ntitle-accent);
}

.item .top .title:empty::after {
  content: "<blank>";
}

.item .bottom {
  margin-top: -14px;
  padding-left: 14px;
}

.item .bottom a {
  color: var(--link);
  font-size: var(--font-size-link);
}

.has-dark .item .bottom a {
  color: var(--nlink);
}

.item .bottom a match {
  color: var(--nlink-accent);
  text-decoration: none;
}

.has-dark .item .bottom a match {
  color: var(--nlink-accent);
}

/* #find */
* {
/*insertroot*/
  --font-size: 17px;
  --font-size-link: 12px;
  --font-weight: normal;
  --font: Source Code Pro, sans;
  --padding: 0px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);

  /* ----------  DAY THEME  ---------- */
  --bg: #282c34;
  --fg: #969ca8;
  --accent-fg: #2e323c;
  --border: #000000;
  --title: #969ca8;
  --title-accent: #4892c6;
  --link: #6b7176;
  --link-accent: #d7ae74;
  
  /* ---------- NIGHT THEME ---------- */
  --nbg: #282c34;
  --nfg: #969ca8;
  --naccent-fg: #2e323c;
  --nborder: #000000;
  --ntitle: #969ca8;
  --ntitle-accent: #4892c6;
  --nlink: #6b7176;
  --nlink-accent: #d7ae74;


  font-family: var(--font);
  /*font-size: var(--font-size);*/
}


.r {
  color: var(--title-accent);
  background: var(--bg);
  border: none;
  box-shadow: none;
}

.r.D {
  color: var(--ntitle-accent);
  background: var(--nbg);
}

#i {
  color: var(--link-accent);
}

.D #i {
  color: var(--nlink-accent);
}


/* #find:host */


/* #find:selection */

lazyvim

下载powershell

下载Neovim

下载lazyvim的配置

相关推荐
Mortal_hhh1 小时前
VScode的C/C++点击转到定义,不是跳转定义而是跳转声明怎么办?(内附详细做法)
ide·vscode·stm32·编辑器
电子云与长程纠缠11 小时前
UE5.3中通过编辑器工具创建大纲菜单文件夹
java·ue5·编辑器
lucky九年12 小时前
vscode翻译插件
ide·vscode·编辑器
真·Wild·攻城狮13 小时前
【码农日常】Vscode Clangd初始化失败(Win10)
ide·vscode·编辑器
七灵微13 小时前
【测试】【Debug】vscode中同一个测试用例出现重复
ide·vscode·编辑器
励志成为嵌入式工程师18 小时前
c语言简单编程练习9
c语言·开发语言·算法·vim
WZF-Sang1 天前
Linux—进程学习-01
linux·服务器·数据库·学习·操作系统·vim·进程
leptune1 天前
coding程序猿的专属vim
vim
4U2471 天前
Linux入门之vim
linux·编辑器·vim·命令模式·底行模式
Liquor14191 天前
vim 编辑器
java·linux·c语言·开发语言·python·编辑器·vim