https://github.com/dmytruek/argument-text-object
Vim plugin for working with function arguments.
https://github.com/dmytruek/argument-text-object
argument arguments vim vim-plugin
Last synced: 9 months ago
JSON representation
Vim plugin for working with function arguments.
- Host: GitHub
- URL: https://github.com/dmytruek/argument-text-object
- Owner: dmyTRUEk
- Created: 2022-09-19T19:34:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-06T08:17:46.000Z (over 3 years ago)
- Last Synced: 2025-09-08T23:34:23.214Z (9 months ago)
- Topics: argument, arguments, vim, vim-plugin
- Language: Vim Script
- Homepage:
- Size: 22.5 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Argument Text Object
Vim plugin for working with function arguments.
This plugin (kinda) provides a text-object `a`(argument).
- `via`, `vaa` - select in/an arg
- `dia`, `daa` - delete in/an arg
- `cia`, `caa` - change in/an arg
- `yia`, `yaa` - yank (copy) in/an arg
- `]a`, `[a` - jump to next/prev arg
This plugin does more than simply `f,dT,`,
because it recognizes the inclusion relationship of parentheses.
**⚠ WARNING ⚠:** this plugin is in experimental phase,
so feature set and provided commands may vary a lot.
## Examples
Here `|` denotes cursor position.
| Explanation | Text before | Input | Text after |
|-----------------------|-------------------|----------------------------------------|---------------------|
| Delete an argument | `foo(ba\|r, baz)` | press `daa` | `foo(\|baz)` |
| Delete in argument | `foo(ba\|r, baz)` | press `dia` | `foo(\|, baz)` |
| Change in argument | `foo(ba\|r, baz)` | press `cia`, type `abc`, press `` | `foo(abc\|, baz)` |
| Select in argument | `foo(ba\|r, baz)` | press `via` | `foo(\|bar\|, baz)` |
| Jump to next argument | `foo(ba\|r, baz)` | press `]a` | `foo(bar, \|baz)` |
## Installation
Just enable it in your preferable plugin manager.
Using [vim-plug](https://github.com/junegunn/vim-plug):
```
Plug 'dmytruek/argument-text-object'
```
Using [packer](https://github.com/wbthomason/packer.nvim):
```
use 'dmytruek/argument-text-object'
```
## Configuration
### Change or disable keybinds:
If you don't like default keybinds, you can disable them:
```
let g:argtextobj_disable_remaps = 1
```
And set your own
(be sure not to map functions meant for visual mode to normal mode and vice versa):
```
xnoremap aa :ArgtextobjXaa
nnoremap daa :ArgtextobjNdaa
nnoremap caa :ArgtextobjNcaa
nnoremap yaa :ArgtextobjNyaa
xnoremap ia :ArgtextobjXia
nnoremap dia :ArgtextobjNdia
nnoremap cia :ArgtextobjNcia
nnoremap yia :ArgtextobjNyia
nnoremap [a :ArgtextobjNpa
nnoremap ]a :ArgtextobjNna
```
### Search limit:
Change search limit:
```
let g:argtextobj_search_limit = 1000
```
## Todo
- add options to disable certain brackets , e.g. triangle brackets (bc they are used as greater/less symbol) (and other?)
- select even when cursor is on bracket character
- select more if some selection already exists (`vaaaa` - select one more argument)
- select even more if all inside parentheses already selected
- make `[a` goto begin of prev arg, not end
- make `ia`, `aa` really text-object, not just binds
- ? make it a bit smarter, so that it works as expected even when any of `<`,`>`,`<=`,`>=` is in arg, e.g. `func(arg1, x < y, arg2)`
If you have some other suggestions, feel free to [open an issue](https://github.com/dmyTRUEk/argument-text-object/issues/new).
## Ideas
- shift args (`a` - move current arg to right)
## Alternatives
- [PeterRincker/vim-argumentative](https://github.com/PeterRincker/vim-argumentative) - argument text object, move cursor between args, shift args to left/right
- [hgiesel/vim-motion-sickness](https://github.com/hgiesel/vim-motion-sickness#field-text-objects) - contains motions for arguments in specified brackets
- [AndrewRadev/sideways.vim](https://github.com/AndrewRadev/sideways.vim) - shift arg to left/right
- [machakann/vim-swap](https://github.com/machakann/vim-swap) - shift arg to left/right, arg swap mode (ala sub-mode)
- [mizlan/iswap.nvim](https://github.com/mizlan/iswap.nvim) - interactive swap args mode
- [vim-scripts/swap-parameters](https://github.com/vim-scripts/swap-parameters) - swap args