Communitygithub.com

G1Joshi/Agent-Skills

专业的Vim辅助工具,涵盖模式编辑、.vimrc配置、寄存器、宏、搜索替换及vim-plug插件管理。适用于终端环境下的高效文本编辑、Vimscript编写、宏录制以及核心Vim配置。

Agent-Skills 是什么?

该技能提供全面的Vim操作辅助,专为需要高效文本编辑的开发者设计。它支持在多种平台上进行系统配置、代码编辑和文本处理,适用范围包括服务器环境、Git提交消息编辑以及大规模宏自动化。技能详细介绍核心概念,如现代生产环境下的.vimrc配置(包含通用设置、插件管理器vim-plug和代码导航),以及模态导航、操作符-文本对象组合(如“ci"

兼容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/G1Joshi/Agent-Skills/tree/HEAD/skills/tools/vim

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Vim

Vim 是每台 UNIX 系统上安装的通用文本编辑器。Neovim 不断创新,而 Vim 则专注于向后兼容性和稳定性。

使用场景

  • 通用服务器和系统编辑:在任何 Unix/Linux 服务器上编辑系统配置、脚本和代码,无需安装附加软件。
  • 模式化文本操作:使用操作符-移动语法(dap、ci"、gUiw)组合文本变换。
  • 无头宏自动化:录制并重放跨上百行的重复编辑操作(qa、@a)。
  • Git 提交和合并编辑:快速交互式编辑提交信息、交互式变基和差异冲突解决。

快速开始

1. 最小化 ~/.vimrc

syntax on
set number
set relativenumber
set tabstop=2
set shiftwidth=2
set expandtab
set hlsearch
set incsearch
set clipboard=unnamed

let mapleader = " "
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>

2. 核心编辑命令

  • i / a:插入模式(光标前/后)
  • ci":更改引号内的内容
  • da{:删除花括号内的内容(含花括号)
  • :%s/foo/bar/g:将文件中所有 foo 替换为 bar
  • . :重复上一次修改

核心概念

现代生产环境 Vimrc(~/.vimrc)

配置合理的默认设置、插件管理器以及代码导航:

" ~/.vimrc
set nocompatible
filetype plugin indent on
syntax on

" 通用设置
set number
set relativenumber
set expandtab
set shiftwidth = 2
set tabstop = 2
set autoindent
set smartindent
set hlsearch
set incsearch
set ignorecase
set smartcase
set hidden
set backspace=indent,eol,start
set updatetime=300
set clipboard=unnamed

" 领导键映射
let mapleader = " "

" 快速窗口导航
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" 清除搜索高亮
nnoremap <leader>h :nohlsearch<CR>

关键文本对象与语法

组合操作符(d、c、y、v)与文本对象和移动:

ci"      - 更改双引号内的内容("foo" -> "")
di(      - 删除括号内的内容
yap      - 复制(拷贝)段落
gUiw     - 将当前单词转换为大写
dt,      - 从光标位置删除直到逗号(不含逗号)
.        - 立即重复上一次修改

宏录制与执行

自动执行重复的表格数据转换:

1. 按 `qa` 开始录制宏到寄存器 'a'
2. 执行文本编辑步骤(例如 `0iconst <Esc>A = true;<Esc>j`)
3. 按 `q` 完成录制
4. 在当前行重放宏:`@a`
5. 跨 50 行重放宏:`50@a`
6. 在可视选择上执行宏:`:'<,'>normal @a`

常见模式

宏录制与批量执行

问题:对多行执行重复的多步编辑。 解决方案:将按键序列录制到寄存器 q。

  1. 将光标置于目标起始位置。
  2. 按 qq 开始录制到寄存器 q。
  3. 执行编辑序列(例如 I" <Esc> A",<Esc> j ^)。
  4. 按 q 停止录制。
  5. 使用 @q 重放,或在 50 行上执行:50@q。

使用 vim-plug 进行插件管理

问题:安装和组织 Vim 插件而无需手动处理路径。 解决方案:使用 vim-plug。

call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-fugitive'
Plug 'preservim/nerdtree'
call plug#end()

在 Vim 内运行 :PlugInstall 进行安装。

最佳实践(2026)

  • 务必掌握模式导航(h、j、k、l、w、b、e)并避免使用方向键。
  • 务必利用文本对象(ciw、da(、yi{)以最少的按键次数编辑结构化代码块。
  • 务必使用点命令(.)跨相似行重复最近的文本转换。
  • 务必启用 set hidden,以便缓冲区可以在后台保持打开状态,无需强制立即保存。
  • 不要安装数百个沉重的旧版 VimScript 插件;如需丰富的 IDE 体验,请过渡到 Neovim Lua。
  • 不要留下交换文件(.swp);配置 set noswapfile 或设置专用交换目录。
  • 不要在 ~/.vimrc 中使用同步外部调用,这会导致远程机器上出现明显的启动延迟。

故障排除

错误/症状原因解决方案
系统剪贴板复制失败("+y无反应)Vim 编译时未启用 +clipboard支持安装带有剪贴板支持的 vim-gtk3(Ubuntu)或 macvim / neovim。
方向键插入 A、B、C、D 字符运行在严格的 Vi 兼容模式在 ~/.vimrc 顶部添加 set nocompatible。
搜索后尾部空白高亮仍然显示搜索高亮保持激活状态输入 :nohlsearch 或绑定 <leader>h :nohlsearch<CR>。

参考

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

G1Joshi/Agent-Skills

Expert Dask distributed computing assistance covering Dask DataFrames, Arrays, Futures, and cluster scaling. Use when analyzing datasets too large for pandas on a single machine or multi-node cluster.

G1Joshi/Agent-Skills

Expert dbt (data build tool) assistance covering SQL modeling, Jinja macros, tests, documentation, and semantic layer. Use when building analytics engineering pipelines on BigQuery, Snowflake, or PostgreSQL.

G1Joshi/Agent-Skills

Expert JAX assistance covering Autograd, XLA compilation (`jit`), vectorization (`vmap`), and parallelization (`pmap`). Use when building high-performance numerical computing and cutting-edge deep learning research.

G1Joshi/Agent-Skills

Expert Ray distributed computing assistance covering Ray Core (actors, tasks), Ray Train, Ray Tune, and Ray Serve. Use when scaling Python compute and ML training across multi-node clusters.

G1Joshi/Agent-Skills

Expert Git version control assistance covering branching, interactive rebase, cherry-pick, submodules, worktrees, and conflict resolution. Use when managing source code history and collaboration workflows.

G1Joshi/Agent-Skills

Expert K9s CLI assistance covering terminal Kubernetes cluster navigation, real-time log streaming, port forwarding, and pod debugging. Use when managing and troubleshooting Kubernetes clusters with speed.

G1Joshi/Agent-Skills

Expert SWC assistance covering high-performance Rust-based JavaScript/TypeScript compilation, .swcrc configuration, Jest testing via @swc/jest, and minification. Use when replacing Babel with SWC for faster builds, accelerating test execution, or compiling modern ECMAScript features.

G1Joshi/Agent-Skills

Expert Tig assistance covering text-mode interface for Git, interactive staging, commit graph visualization, diff exploration, and blame navigation. Use when navigating Git commit history in the terminal, staging hunks interactively, browsing file changes, or reviewing revisions.

G1Joshi/Agent-Skills

Expert Zed editor assistance covering high-performance Rust-based text editing, multi-buffer editing, language server protocols (LSP), and AI assistant integrations. Use when configuring Zed settings.json, setting up language extensions, collaborating in real-time channels, or optimizing editor startup speed.

G1Joshi/Agent-Skills

Expert Zsh assistance covering shell customization, Oh My Zsh plugins, Zinit plugin manager, prompt engineering (Starship/Powerlevel10k), and shell scripting. Use when configuring .zshrc, writing Zsh automation scripts, optimizing shell startup time, or configuring tab-completion.

G1Joshi/Agent-Skills

Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].

相关技能