mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-05-18 05:37:21 +02:00
security(home): drop all neovim plugins to shrink supply-chain exposure (#259)
* chore(home): drop AstroNvim bundle and centralize editors Remove the bundled Neovim plugin tree to shrink supply-chain exposure; keep a minimal programs.neovim backup. Daily editing stays Helix-first with Yazi and Zellij. - Add Helix/Neovim docs, glossary, and cheatsheets under core/editors/. - Default EDITOR/VISUAL to hx; use SUDO_EDITOR nvim --clean for sudoedit and other sensitive edits; adjust Nushell buffer_editor accordingly. - Apply Helix Home Manager settings (keys, editor UI) in core/editors/helix. - Keep heavy language-server tooling only in home/base/tui/editors/packages.nix; wire it via an explicit default.nix import so core stays lightweight. - Extend modules/base packages.nix where that profile sets global editor env. * docs: link editors, VS Code, and agents from README Document tui/editors versus core/editors; add root README pointers to GUI vscode (Home Manager) and agents/. Cross-link heavy packages README from core/editors.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# Editors Glossary
|
||||
|
||||
### LSP - Language Server Protocol
|
||||
|
||||
> https://en.wikipedia.org/wiki/Language_Server_Protocol
|
||||
|
||||
> https://langserver.org/
|
||||
|
||||
The Language Server Protocol (LSP) is an open, JSON-RPC-based protocol for use between source code
|
||||
editors or integrated development environments (IDEs) and servers that provide programming
|
||||
language-specific features like:
|
||||
|
||||
- motions such as go-to-definition, find-references, hover.
|
||||
- **code completion**
|
||||
- **marking of warnings and errors**
|
||||
- **refactoring routines**
|
||||
- syntax highlighting (use Tree-sitter instead)
|
||||
- code formatting (use a dedicated formatter instead)
|
||||
|
||||
The goal of the protocol is to allow programming language support to be implemented and distributed
|
||||
independently of any given editor or IDE.
|
||||
|
||||
LSP was originally developed for Microsoft Visual Studio Code and is now an open standard. In the
|
||||
early 2020s LSP quickly became a "norm" for language intelligence tools providers.
|
||||
|
||||
### Tree-sitter
|
||||
|
||||
> https://tree-sitter.github.io/tree-sitter/
|
||||
|
||||
> https://www.reddit.com/r/neovim/comments/1109wgr/treesitter_vs_lsp_differences_ans_overlap/
|
||||
|
||||
Tree-sitter is a parser generator tool and an **incremental parsing** library. It can build a
|
||||
concrete syntax tree for a source file and efficiently update the syntax tree as the source file is
|
||||
edited.
|
||||
|
||||
It is used by many editors and IDEs to provide:
|
||||
|
||||
- **syntax highlighting**
|
||||
- **indentation**
|
||||
- **creating foldable code regions**
|
||||
- **Incremental selection**
|
||||
- **simple refactoring in a single file**
|
||||
- such as join/split lines, structural editing, cursor motion, etc.
|
||||
|
||||
**Treesitter process each file independently**, and it is not aware of the semantics of your code.
|
||||
For example, it does not know does a function/variable really exist, or what is the type/return-type
|
||||
of a variable. This is where LSP comes in.
|
||||
|
||||
The LSP server parses the code much more deeply and it **not only parses a single file but your
|
||||
whole project**. So, the LSP server will know whether a function/variable does exist with the same
|
||||
type/return-type. If it does not, it will mark it as an error.
|
||||
|
||||
**LSP does understand the code semantically, while Treesitter only cares about correct syntax**.
|
||||
|
||||
#### LSP vs Tree-sitter
|
||||
|
||||
- Tree-sitter: lightweight, fast, but limited knowledge of your code. mainly used for **syntax
|
||||
highlighting, indentation, and folding/refactoring in a single file**.
|
||||
- LSP: heavy and slow on large projects, but it has a deep understanding of your code. mainly used
|
||||
for **code completion, refactoring in the projects, errors/warnings, and other semantic-aware
|
||||
features**.
|
||||
|
||||
### Formatter vs Linter
|
||||
|
||||
Linting is distinct from Formatting because:
|
||||
|
||||
1. **formatting** only restructures how code appears.
|
||||
1. `prettier` is a popular formatter.
|
||||
1. **linting** analyzes how the code runs and detects errors, it may also suggest improvements such
|
||||
as replace `var` with `let` or `const`.
|
||||
|
||||
Formatters and Linters process each file independently, they do not need to know about other files
|
||||
in the project.
|
||||
@@ -1,10 +1,26 @@
|
||||
# Editors
|
||||
|
||||
This directory contains editor configurations that are shared across different environments.
|
||||
Shared editor configuration and **usage notes** for terminal-focused editing.
|
||||
|
||||
## Available Editors
|
||||
## Roles
|
||||
|
||||
- **neovim/**: Neovim configuration with AstroNvim
|
||||
- **helix/**: Helix editor configuration
|
||||
- **Helix** (`helix/`): Primary TUI editor — batteries-included, small attack surface. `$EDITOR` /
|
||||
`$VISUAL` default to `hx` (`session-env.nix`).
|
||||
- **Neovim** (`neovim/`): Backup editor — classic vim-style workflow and `:help` when needed. For
|
||||
privileged edits (`sudoedit`) and other security-sensitive inputs, `$SUDO_EDITOR` is
|
||||
`nvim --clean`; use that explicitly when `$EDITOR` must avoid user config/plugins.
|
||||
|
||||
These configurations are designed to work across both terminal and GUI environments.
|
||||
Terminal layout and files: **Zellij** and **Yazi** live under `core/zellij/` and `core/yazi.nix`
|
||||
(not in this folder).
|
||||
|
||||
## Docs
|
||||
|
||||
- [`helix/README.md`](./helix/README.md) — Helix basics, cheatsheet, official doc links, Helix vs
|
||||
Neovim notes.
|
||||
- [`neovim/README.md`](./neovim/README.md) — Vim/Neovim basics, cheatsheet, and official doc links.
|
||||
|
||||
Nix modules in `helix/` and `neovim/` enable each editor via Home Manager. Language servers and
|
||||
other heavy editor-related packages are listed in
|
||||
[`../../tui/editors/`](../../tui/editors/README.md) (imported from `home/base/tui`).
|
||||
|
||||
Editor terminology (LSP, tree-sitter): [`Glossary.md`](./Glossary.md).
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
# Helix (primary) — Kakoune-style usage
|
||||
|
||||
Neovim is powerful and has a very active community. This config still enables Neovim as a **backup**
|
||||
editor (vim-style muscle memory, `:help`, and occasional plugin workflows).
|
||||
|
||||
Helix is the **primary** TUI editor here: opinionated, batteries-included (LSP, tree-sitter, picker,
|
||||
multi-cursor, surround), and a smaller moving part than a large Neovim plugin stack.
|
||||
|
||||
## Tips
|
||||
|
||||
1. This flake sets `$EDITOR` / `$VISUAL` to **`hx`** by default. For security-sensitive edits
|
||||
(privileged files, unfamiliar binaries, secrets), prefer **`nvim --clean`** — `$SUDO_EDITOR` uses
|
||||
it so `sudoedit` stays minimal; invoke it yourself in other trust-boundary cases.
|
||||
1. Helix is **selection-first** (like Kakoune): extend a selection, then run an action (`d`, `c`,
|
||||
`y`, …). A lone cursor is a zero-width selection.
|
||||
1. Read the official docs before reinventing workflows:
|
||||
1. <https://docs.helix-editor.com/> — documentation home (links to usage, keymap, configuration).
|
||||
1. <https://docs.helix-editor.com/usage.html> — modes, buffers, motions overview.
|
||||
1. <https://docs.helix-editor.com/keymap.html> — full default keybindings.
|
||||
1. <https://docs.helix-editor.com/commands.html> — typable commands (`:` prompt).
|
||||
1. <https://docs.helix-editor.com/configuration.html> — `config.toml`, themes, remaps.
|
||||
1. <https://github.com/helix-editor/helix/wiki> — install tips, language servers, FAQ.
|
||||
1. Prefer **Zellij** for shells and panes; use **Helix** for buffers and text.
|
||||
1. On large codebases, navigation is often **by picker** (`Space f`, symbols, workspace search) or
|
||||
**by LSP** (`g` goto mode), complementing motion-based editing.
|
||||
|
||||
## Tutorial
|
||||
|
||||
Run `:tutor` inside Helix, or `hx --tutor` from the shell
|
||||
([tutor source](https://github.com/helix-editor/helix/blob/master/runtime/tutor)).
|
||||
|
||||
## Helix cheatsheet (common keys)
|
||||
|
||||
> Full reference: <https://docs.helix-editor.com/keymap.html>
|
||||
> Typable commands: <https://docs.helix-editor.com/commands.html>
|
||||
|
||||
### Terminal related
|
||||
|
||||
Zellij shortcuts used often (same idea as in the Neovim notes):
|
||||
|
||||
| Action | Zellij shortcut |
|
||||
| ------------------------- | --------------- |
|
||||
| Floating terminal | `Ctrl + p + w` |
|
||||
| Horizontal split terminal | `Ctrl + p + d` |
|
||||
| Vertical split terminal | `Ctrl + p + n` |
|
||||
|
||||
In Helix, `|` / `!` and variants pipe or insert shell output on selections (see **Changes**).
|
||||
|
||||
### Command mode (`:`)
|
||||
|
||||
> <https://docs.helix-editor.com/commands.html>
|
||||
|
||||
| Action | Command examples |
|
||||
| ---------------------- | ------------------------------------------ |
|
||||
| Write / write all | `:w` / `:wa` |
|
||||
| Quit view / quit all | `:q` / `:qa` — add `!` to discard changes |
|
||||
| Write and quit | `:wq`, `:x` |
|
||||
| Write all and quit all | `:wqa`, `:xa` |
|
||||
| Open file | `:open path`, `:e path` |
|
||||
| Next / previous buffer | `:bn` / `:bp` (also `gn` / `gp` in normal) |
|
||||
| Close buffer | `:bc` (add `!` to force) |
|
||||
| Reload from disk | `:reload` |
|
||||
| Change directory / pwd | `:cd` / `:pwd` |
|
||||
| Split open file | `:vs path`, `:hs path` |
|
||||
|
||||
### Movement (normal mode)
|
||||
|
||||
| Action | Keys / notes |
|
||||
| --------------------- | --------------------------------------------------- |
|
||||
| Arrow keys | `h` `j` `k` `l` |
|
||||
| Words | `w` `b` `e` — `W` `B` `E` for WORD-style |
|
||||
| Find char / till char | `f` `F` `t` `T` (not limited to current line) |
|
||||
| Line / file | `Home` / `End`; `gg` start or goto line; `G` line |
|
||||
| Half / full page | `Ctrl-u` / `Ctrl-d`; `Ctrl-b` / `Ctrl-f` |
|
||||
| Jumplist | `Ctrl-o` back, `Ctrl-i` forward; `Ctrl-s` save spot |
|
||||
|
||||
### Selection & changes
|
||||
|
||||
| Action | Keys / notes |
|
||||
| ---------------------- | ----------------------------------------------------------------- | ------------------- | -------------------------------------------- |
|
||||
| Extend selections | `v` select mode; motions extend instead of moving |
|
||||
| Line selection | `x` extend line; `X` line bounds |
|
||||
| Select all / regex | `%`; `s` regex in selections; `S` split on regex |
|
||||
| Undo / redo | `u` / `U` |
|
||||
| Delete / change / yank | `d` / `c` / `y` — acts on selection |
|
||||
| Paste | `p` / `P`; registers `"` … |
|
||||
| Insert | `i` `a` `I` `A` `o` `O` |
|
||||
| Indent / format | `>` / `<`; `=` format (LSP) |
|
||||
| Case | `~` toggle; lower/upper case via grave / `Alt-grave` (see keymap) |
|
||||
| Join lines | `J`; `Alt-J` join keeping space |
|
||||
| Shell | ` | `pipe replace;`Alt- | `pipe to;`!` insert output before selections |
|
||||
|
||||
### Search
|
||||
|
||||
| Action | Keys |
|
||||
| -------------------- | ---------------------------------------- |
|
||||
| Search / reverse | `/` / `?` |
|
||||
| Next / prev match | `n` / `N` |
|
||||
| Selection as pattern | `*` (word bounds); `Alt-*` raw selection |
|
||||
|
||||
Use **extend mode** (`v`) with `n` / `N` to add matches to multi-cursors
|
||||
([keymap](https://docs.helix-editor.com/keymap.html#select--extend-mode)).
|
||||
|
||||
### Replace / multi-occur edits
|
||||
|
||||
Helix has no vim-style `:%s` with preview. Typical patterns:
|
||||
|
||||
- Select matches with `s` or search, then `c` to change all selections at once.
|
||||
- Workspace-wide search: `Space /` (global search picker).
|
||||
- Heavy refactors: external tools or another pane (see **Differences** below).
|
||||
|
||||
### Goto mode (`g` then …)
|
||||
|
||||
| Action | Keys (after `g`) |
|
||||
| -------------------- | ---------------- |
|
||||
| File start / end | `g` / `e` |
|
||||
| Line start / end | `h` / `l` |
|
||||
| First non-whitespace | `s` |
|
||||
| Definition / refs | `d` / `r` (LSP) |
|
||||
| Type / impl | `y` / `i` (LSP) |
|
||||
| Next / prev buffer | `n` / `p` |
|
||||
|
||||
Also: `gd` / `gD` definition/declaration-style jumps where bound.
|
||||
|
||||
### Match mode (`m` …)
|
||||
|
||||
Surround and textobjects: see <https://docs.helix-editor.com/surround.html> and
|
||||
<https://docs.helix-editor.com/textobjects.html>. Matching bracket: `mm` (tree-sitter).
|
||||
|
||||
### Window mode (`Ctrl-w` then …)
|
||||
|
||||
| Action | Keys |
|
||||
| ---------------- | --------------- |
|
||||
| Next window | `w` |
|
||||
| Vertical split | `v` |
|
||||
| Horizontal split | `s` |
|
||||
| Focus splits | `h` `j` `k` `l` |
|
||||
| Close / only | `q` / `o` |
|
||||
|
||||
### Space mode (`Space` then …)
|
||||
|
||||
| Action | Keys |
|
||||
| -------------------- | ------------------ |
|
||||
| File picker (roots) | `f` |
|
||||
| File picker (cwd) | `F` |
|
||||
| Buffer picker | `b` |
|
||||
| Global search | `/` |
|
||||
| Command palette | `?` |
|
||||
| Hover docs (LSP) | `k` |
|
||||
| Symbols / workspace | `s` / `S` |
|
||||
| Diagnostics | `d` / `D` |
|
||||
| Clipboard yank/paste | `y` / `p` variants |
|
||||
|
||||
Picker movement: <https://docs.helix-editor.com/pickers.html>.
|
||||
|
||||
### Minor modes from normal
|
||||
|
||||
| Mode | Key |
|
||||
| ----------- | --------- |
|
||||
| Command | `:` |
|
||||
| View scroll | `z` / `Z` |
|
||||
| Goto | `g` |
|
||||
| Match | `m` |
|
||||
| Window | `Ctrl-w` |
|
||||
|
||||
Some bindings need an **LSP** or **tree-sitter** grammar; see notes on the keymap page.
|
||||
|
||||
## Differences between Neovim and Helix
|
||||
|
||||
1. Selecting first, then action.
|
||||
1. Helix: delete 2 words: move/select with `w` … then `d`. You see the selection before the
|
||||
action.
|
||||
2. Neovim: delete 2 words: `d` then `2w`. No visual feedback before the action runs.
|
||||
1. Helix — modern built-in features: LSP, tree-sitter, fuzzy finder, multi-cursors, surround, and
|
||||
more.
|
||||
1. The same is available in Neovim, but usually via plugins you choose and maintain.
|
||||
1. Helix is built in Rust from scratch: smaller codebase, modern defaults. No VimScript, no Lua in
|
||||
user config.
|
||||
1. Neovim carries Vim heritage (VimScript) and Lua-heavy customization.
|
||||
1. Neovim has a huge plugin ecosystem.
|
||||
1. Helix is newer; a stable plugin system is still evolving:
|
||||
<https://github.com/helix-editor/helix/pull/8675>
|
||||
1. Neovim has an integrated terminal (similar in spirit to VS Code’s).
|
||||
1. Helix does not ship one; use Zellij / tmux / terminal features instead.
|
||||
1. <https://github.com/helix-editor/helix/issues/1976#issuecomment-1091074719>
|
||||
1. <https://github.com/helix-editor/helix/pull/4649>
|
||||
1. Helix has no built-in tree panel; pair with **Yazi**, ranger, or Broot and open files from there.
|
||||
1. A tree view may arrive with plugins later; many users rely on the file picker instead.
|
||||
1. Global substitution is weaker in Helix; run replacements in another pane (Zellij) or an external
|
||||
tool when needed.
|
||||
1. <https://github.com/helix-editor/helix/issues/196>
|
||||
1. Neovim’s `:s` with preview remains strong for interactive refactors; external tools (e.g.
|
||||
<https://github.com/ms-jpq/sad>) can fill gaps in Helix-centric flows.
|
||||
1. Complexity vs batteries-included tradeoffs:
|
||||
<https://github.com/helix-editor/helix/discussions/6356>
|
||||
|
||||
Using **Helix** (and Neovim when useful) inside **Yazi** and **Zellij** keeps editing, files, and
|
||||
panes explicit and scriptable — different from a single IDE window, but very composable.
|
||||
|
||||
Helix nudges you away from reproducing VS Code/JetBrains inside one process; Neovim remains there
|
||||
when you want that depth.
|
||||
@@ -1,4 +1,32 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs.helix.enable = true;
|
||||
programs.helix = {
|
||||
enable = true;
|
||||
package = pkgs.helix;
|
||||
settings = {
|
||||
editor = {
|
||||
line-number = "relative";
|
||||
cursorline = true;
|
||||
color-modes = true;
|
||||
lsp.display-messages = true;
|
||||
cursor-shape = {
|
||||
insert = "bar";
|
||||
normal = "block";
|
||||
select = "underline";
|
||||
};
|
||||
indent-guides.render = true;
|
||||
};
|
||||
keys.normal = {
|
||||
space = {
|
||||
space = "file_picker";
|
||||
w = ":w";
|
||||
q = ":q";
|
||||
};
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"keep_primary_selection"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
# Neovim (backup) — vim-style usage
|
||||
|
||||
Primary day-to-day editing is **Helix**; this file is the **vim/Neovim** quick reference and doc
|
||||
pointers for when you reach for Neovim as a backup.
|
||||
|
||||
## Tips
|
||||
|
||||
1. Many motions already exist in vim — check vim/Neovim docs before adding plugins or reinventing
|
||||
wheels.
|
||||
1. For deeper skill, read the official docs:
|
||||
1. <https://vimhelp.org/> — vim help.
|
||||
1. <https://neovim.io/doc/user/> — Neovim user manual.
|
||||
1. Prefer **Zellij** for shells and panes; use **Helix** or **Neovim** for buffers and text.
|
||||
1. Two powerful navigation modes on large codebases:
|
||||
1. **By path** — when you know the tree layout.
|
||||
1. **By content** — when you know what the code says.
|
||||
|
||||
## Tutorial
|
||||
|
||||
Type `:tutor` (or `:Tutor` in Neovim) for the built-in vim tutorial.
|
||||
|
||||
## Vim cheatsheet (common keys)
|
||||
|
||||
> For a fuller reference: <https://vimhelp.org/quickref.txt.html>
|
||||
|
||||
Emacs Evil, Neovim, and vim share the motions below.
|
||||
|
||||
### Terminal related
|
||||
|
||||
Zellij shortcuts used often:
|
||||
|
||||
| Action | Zellij shortcut |
|
||||
| ------------------------- | --------------- |
|
||||
| Floating terminal | `Ctrl + p + w` |
|
||||
| Horizontal split terminal | `Ctrl + p + d` |
|
||||
| Vertical split terminal | `Ctrl + p + n` |
|
||||
| Run a shell command | `!xxx` |
|
||||
|
||||
### File management
|
||||
|
||||
> <https://neovim.io/doc/user/usr_22.html>
|
||||
> <https://vimhelp.org/editing.txt.html>
|
||||
|
||||
| Action | Command |
|
||||
| ----------------------------- | -------------------------------------------- |
|
||||
| Save selection to a file | `:w filename` (shows `:'<,'>w filename`) |
|
||||
| Save and close current buffer | `:wq` |
|
||||
| Save all buffers | `:wa` |
|
||||
| Save and close all buffers | `:wqa` |
|
||||
| Edit a file | `:e filename` (or `:e <TAB>` for completion) |
|
||||
| Browse files | `:Ex` or `:e .` |
|
||||
| Discard changes and reload | `:e!` |
|
||||
|
||||
### Motion
|
||||
|
||||
> <https://vimhelp.org/motion.txt.html>
|
||||
|
||||
| Action | Command |
|
||||
| ----------------------------------- | --------------------------------------- |
|
||||
| Start / end of buffer | `gg` / `G` |
|
||||
| Go to line 5 | `5gg` / `5G` |
|
||||
| Left / down / up / right | `h` `j` `k` `l` (counts like `5j` work) |
|
||||
| Jump to matchpairs `()`, `{}`, `[]` | `%` |
|
||||
| Start / end of line | `0` / `$` |
|
||||
| Sentence forward / backward | `(` / `)` |
|
||||
| Paragraph forward / backward | `{` / `}` |
|
||||
| Section forward / backward | `[[` / `]]` |
|
||||
| Jump to marks | `'` + mark (Neovim may prompt) |
|
||||
|
||||
Text objects:
|
||||
|
||||
- **Sentence**: ends at `.` `!` `?` plus line end or space/tab.
|
||||
- **Paragraph**: ends at a blank line.
|
||||
- **Section**: between section headers; `[[` / `]]` often stop at `{` in column 1 (handy in
|
||||
C/Go/Java).
|
||||
|
||||
### Text manipulation
|
||||
|
||||
Basics:
|
||||
|
||||
| Action | Command |
|
||||
| ----------------------------- | ------------------------------ |
|
||||
| Delete character under cursor | `x` |
|
||||
| Put (paste) | `p` |
|
||||
| Delete operator + motion | `d` |
|
||||
| Undo word (insert) | `CTRL-w` |
|
||||
| Undo line (insert) | `CTRL-u` |
|
||||
| Undo change | `u` |
|
||||
| Redo | `Ctrl-r` |
|
||||
| Repeat previous insert | `Ctrl-a` |
|
||||
| Repeat last change | `.` |
|
||||
| Toggle case | `~` |
|
||||
| Uppercase (visual) | `U` |
|
||||
| Lowercase (visual) | `u` |
|
||||
| Align selection | `:center` / `:left` / `:right` |
|
||||
|
||||
Misc:
|
||||
|
||||
| Action | Shortcut |
|
||||
| ------------------------ | ----------- |
|
||||
| Character-wise visual | `v` |
|
||||
| Line-wise visual | `V` |
|
||||
| Block visual | `<Ctrl-v>` |
|
||||
| Fold close / open | `zc` / `zo` |
|
||||
| Go to definition | `gd` |
|
||||
| Go to references | `gD` |
|
||||
| Comment line (if mapped) | e.g. `gcc` |
|
||||
|
||||
| Action | Command |
|
||||
| ----------------------------------- | -------------- |
|
||||
| Sort lines | `:sort` |
|
||||
| Join lines | `:join` or `J` |
|
||||
| Join without spaces | `:join!` |
|
||||
| Insert at line start / end | `I` / `A` |
|
||||
| Delete to end of line | `D` |
|
||||
| Change to end of line (into insert) | `C` |
|
||||
|
||||
Advanced patterns:
|
||||
|
||||
- Append to many lines: `:normal A<text>` (often after visual-block `Ctrl-v`).
|
||||
- Neovim may pad short lines with spaces when block-appending past EOL.
|
||||
- Delete last character on many lines: `:normal $x` over a visual selection.
|
||||
- Delete last word on many lines: `:normal $bD`.
|
||||
|
||||
### Search
|
||||
|
||||
| Action | Command |
|
||||
| --------------------------------- | ------- |
|
||||
| Search forward / backward | `/` `?` |
|
||||
| Repeat search same / opposite dir | `n` `N` |
|
||||
|
||||
### Find and replace
|
||||
|
||||
| Action | Command |
|
||||
| ------------------- | ---------------------------------- |
|
||||
| In visual selection | `:s/old/new/g` |
|
||||
| Current line | same |
|
||||
| Whole buffer | `:%s/old/new/g` |
|
||||
| Regex example | `:%s@\vhttp://(\w+)@https://\1@gc` |
|
||||
|
||||
Notes:
|
||||
|
||||
- `\v` — “very magic”, less backslash noise in the pattern.
|
||||
- `\1` — first capture group.
|
||||
|
||||
### Specific line ranges
|
||||
|
||||
| Action | Command examples |
|
||||
| --------------------- | ------------------------------------ |
|
||||
| Lines 10–end | `:10,$s/old/new/g` or `:10,$s@^@#@g` |
|
||||
| Lines 10–20 | `:10,20s/old/new/g` |
|
||||
| Strip trailing spaces | `:%s/\s\+$//g` |
|
||||
|
||||
Flags: `g` all matches in range, `c` confirm each, `i` ignore case.
|
||||
|
||||
### Buffers, windows, tabs
|
||||
|
||||
> <https://neovim.io/doc/user/usr_08.html>
|
||||
> <https://vimhelp.org/windows.txt.html>
|
||||
|
||||
- **Buffer** — in-memory text for a file.
|
||||
- **Window** — viewport on a buffer.
|
||||
- **Tab page** — layout of windows.
|
||||
|
||||
| Action | Command |
|
||||
| ------------------ | ------------------------------ |
|
||||
| Horizontal split | `:sp` or `:sp filename` |
|
||||
| Vertical split | `:vs` or `:vs filename` |
|
||||
| Next / prev window | `Ctrl-w w` or `Ctrl-w h/j/k/l` |
|
||||
| List buffers | `:ls` |
|
||||
| Next / prev buffer | `]b` / `[b` or `:bn` / `:bp` |
|
||||
| New tab | `:tabnew` |
|
||||
| Next / prev tab | `gt` / `gT` |
|
||||
|
||||
### History
|
||||
|
||||
| Action | Command |
|
||||
| --------------- | ------- |
|
||||
| Command history | `q:` |
|
||||
| Search history | `q/` |
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
withRuby = false;
|
||||
withPython3 = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Default interactive editor is Helix (`hx`). For trust-boundary edits (e.g. `sudoedit`,
|
||||
# secrets, unfamiliar payloads), prefer `nvim --clean` — wired via `SUDO_EDITOR`.
|
||||
{
|
||||
home.sessionVariables = {
|
||||
EDITOR = "hx";
|
||||
VISUAL = "hx";
|
||||
SUDO_EDITOR = "nvim --clean";
|
||||
};
|
||||
}
|
||||
@@ -78,9 +78,9 @@ $env.config.recursion_limit = 50
|
||||
$env.config.edit_mode = "vi"
|
||||
|
||||
# Command that will be used to edit the current line buffer with Ctrl+O.
|
||||
# If unset, uses $env.VISUAL and then $env.EDITOR
|
||||
# If unset, uses $env.VISUAL and then $env.EDITOR ($EDITOR is `hx` via session-env).
|
||||
#
|
||||
$env.config.buffer_editor = ["nvim", "--clean"]
|
||||
$env.config.buffer_editor = ["hx"]
|
||||
|
||||
# cursor_shape_* (string)
|
||||
# -----------------------
|
||||
|
||||
Reference in New Issue
Block a user