mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
Replace the monolithic 1268-line .vimrc with a thin loader that sources 12 modules under modules/ (env, plugins, core, ui, editing, navigation, lsp, lint, git, writing, languages, tools). Each module is independently readable and can be toggled by commenting one line. Add interactive tutorial (tutor/chopsticks.tutor) with 10 lessons covering all features. Users can run :ChopsticksLearn to start.
269 lines
9.2 KiB
Text
269 lines
9.2 KiB
Text
================================================================================
|
|
= C H O P S T I C K S I N T E R A C T I V E T U T O R =
|
|
================================================================================
|
|
|
|
This tutorial teaches the key features of the chopsticks Vim configuration.
|
|
It assumes you already know basic Vim (if not, run :Tutor first).
|
|
|
|
Leader key is , (comma) throughout this tutorial.
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 1: SURVIVAL BASICS
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
These four commands get you out of any situation:
|
|
|
|
1. Press Esc or type jk to return to Normal mode
|
|
2. Type ,w to save the current file
|
|
3. Type ,x to save and quit
|
|
4. Type ,q to quit (without saving)
|
|
|
|
TIP: You can also press Ctrl+s to save from ANY mode (normal, insert,
|
|
or visual). Try it now — press i to enter insert mode, then Ctrl+s
|
|
to save without leaving insert mode.
|
|
|
|
When completely lost, press ,? to open the cheat sheet with every
|
|
keybinding. Press q to close it.
|
|
|
|
>>> Try it now: press ,? then read through the sheet, then press q
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 2: FINDING FILES
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
chopsticks uses FZF (fuzzy finder) for fast navigation.
|
|
|
|
Ctrl+p Fuzzy find files (git-aware — ignores .gitignore'd files)
|
|
,b Search open buffers
|
|
,fh Recent file history
|
|
,rg Search file contents with ripgrep
|
|
,rG Search for the word under your cursor
|
|
|
|
>>> Try it now: press Ctrl+p and start typing a filename
|
|
|
|
You can also browse files with the built-in file browser:
|
|
|
|
,e Open netrw file browser in current window
|
|
,E Open netrw in a vertical split
|
|
|
|
Inside netrw:
|
|
Enter Open file
|
|
- Go up one directory
|
|
% Create new file
|
|
d Create new directory
|
|
gh Toggle hidden files
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 3: CODE INTELLIGENCE
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
chopsticks uses vim-lsp for code intelligence — no Node.js required.
|
|
|
|
First, install a language server for your filetype:
|
|
|
|
:LspInstallServer (auto-detects the language)
|
|
:LspStatus (check if it's running)
|
|
|
|
Once a server is running, these keys become available:
|
|
|
|
gd Go to definition
|
|
gy Go to type definition
|
|
gi Go to implementation
|
|
gr List all references
|
|
K Show hover documentation
|
|
|
|
[g / ]g Jump to previous / next diagnostic
|
|
,rn Rename symbol under cursor
|
|
,ca Code action (auto-fix)
|
|
,f Format buffer (or selection in visual mode)
|
|
,o File outline (symbols)
|
|
|
|
>>> Open a source file and try: gd on a function call, then Ctrl+o
|
|
to jump back
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 4: EDITING POWER
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
These editing features make chopsticks faster than vanilla Vim.
|
|
|
|
EASYMOTION — jump anywhere on screen:
|
|
Press s then type two characters from your target location.
|
|
Matching positions light up — press the highlighted letter to jump.
|
|
|
|
>>> Try it now: press s then type two letters you can see on screen
|
|
|
|
MOVE LINES — rearrange code without cut/paste:
|
|
Alt+j Move current line down
|
|
Alt+k Move current line up
|
|
(Works in visual mode too — select lines first with V )
|
|
|
|
SURROUND — change surrounding characters:
|
|
cs"' Change surrounding " to '
|
|
cs'<div> Change surrounding ' to <div>...</div>
|
|
ds( Delete surrounding parentheses
|
|
ysiw" Surround word with "
|
|
|
|
COMMENT — toggle comments:
|
|
gc Toggle comment (works in visual mode on selections)
|
|
gcc Toggle comment on current line
|
|
|
|
VISUAL FEEDBACK:
|
|
- Yanked text flashes briefly so you know what was copied
|
|
- Search highlights auto-clear after you stop moving
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 5: GIT WORKFLOW
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
All git operations through vim-fugitive:
|
|
|
|
,gs Git status (press s to stage, press cc to commit)
|
|
,gd Diff current file (side-by-side split)
|
|
,gb Git blame (who changed each line)
|
|
,gc Git commit
|
|
,gp Git push
|
|
,gl Git pull
|
|
|
|
GitGutter shows changes in the sign column (left margin):
|
|
+ Added line
|
|
~ Modified line
|
|
- Deleted line
|
|
|
|
Navigate git conflict markers:
|
|
]x Jump to next conflict marker
|
|
[x Jump to previous conflict marker
|
|
|
|
>>> Try ,gs in a git repository to see the status view
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 6: MARKDOWN & WRITING
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Markdown files get special treatment automatically:
|
|
- Word wrap enabled
|
|
- Spell checking enabled
|
|
- Syntax concealment (bold renders as bold, headings hide # markers)
|
|
- Folding by heading level
|
|
|
|
Key bindings for markdown:
|
|
|
|
,mp Open live browser preview (auto-refreshes as you type)
|
|
,mt Table of contents in a side window
|
|
,zen Enter zen mode — Goyo + Limelight
|
|
(distraction-free writing, only current paragraph highlighted)
|
|
zr Unfold all headings
|
|
zm Fold all headings
|
|
|
|
>>> Open a .md file and try ,zen to enter zen mode.
|
|
Press ,zen again to leave.
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 7: WINDOW MANAGEMENT
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Navigate between splits (works with tmux panes too):
|
|
|
|
Ctrl+h Move to left split
|
|
Ctrl+j Move to split below
|
|
Ctrl+k Move to split above
|
|
Ctrl+l Move to right split
|
|
|
|
Buffer navigation:
|
|
|
|
,h Previous buffer
|
|
,l Next buffer
|
|
,bd Close buffer (keeps window layout)
|
|
,, Switch to last file (toggle between two files)
|
|
|
|
Window tricks:
|
|
|
|
,z Maximize current window (press again to restore)
|
|
,= / ,- Resize window height (bigger / smaller)
|
|
,+ / ,_ Resize window width (bigger / smaller)
|
|
|
|
Terminal:
|
|
|
|
,tv Open terminal (vertical split)
|
|
,th Open terminal (horizontal, 10 rows)
|
|
Esc Esc Exit terminal mode back to normal
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 8: LINTING & FORMATTING
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
ALE runs linters and formatters automatically:
|
|
|
|
- Linting happens as you type (normal mode) and on save
|
|
- Format-on-save is enabled by default (black, prettier, gofmt, etc.)
|
|
|
|
Navigate errors:
|
|
|
|
[e / ]e Previous / next ALE error
|
|
,aD Show error detail in a popup
|
|
|
|
Supported out of the box:
|
|
Python: flake8 + pylint (lint), black + isort (format)
|
|
JS/TS: eslint (lint), prettier + eslint (format)
|
|
Go: staticcheck (lint), goimports (format)
|
|
Rust: cargo (lint), rustfmt (format)
|
|
Shell: shellcheck (lint)
|
|
And more: yaml, dockerfile, css, markdown, sql
|
|
|
|
>>> Write some intentionally bad code and watch the sign column
|
|
light up with X (error) and ! (warning) markers
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 9: RUNNING CODE
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Press ,cr to run the current file. It auto-detects the language:
|
|
|
|
Python → python3 file.py
|
|
JavaScript → node file.js
|
|
TypeScript → npx ts-node file.ts
|
|
Go → go run file.go
|
|
Rust → cargo run
|
|
Shell → bash file.sh
|
|
C → gcc + run
|
|
Lua, Ruby, Perl also supported
|
|
|
|
>>> Create a test file (e.g. test.py with: print("hello"))
|
|
and press ,cr to run it
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
Lesson 10: DAILY TIPS
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
SEARCH AND REPLACE:
|
|
,* Replace word under cursor throughout the file
|
|
// In visual mode, search for selected text
|
|
|
|
USEFUL SHORTCUTS:
|
|
Y Yank to end of line (consistent with D and C)
|
|
,y / ,Y Yank to system clipboard
|
|
,F Re-indent entire file
|
|
,W Strip all trailing whitespace
|
|
:w!! Sudo save (when you forgot to open as root)
|
|
,ev Edit your vimrc
|
|
,sv Reload your vimrc
|
|
|
|
SESSIONS:
|
|
:Obsess Start recording session (auto-restores next time)
|
|
:Obsess! Stop recording
|
|
|
|
The startup screen (Startify) shows recent files, sessions, and bookmarks.
|
|
|
|
>>> Press ,? one more time to review the full cheat sheet.
|
|
You now know the essential chopsticks features. Happy editing!
|
|
|
|
================================================================================
|