https://github.com/magidc/ideavim-anyobject
Adds useful text objects to improve your productivity on JetBrains IDEs. Text objects provide a more natural way to tell the editor what to edit, select or jump. Instead of working with characters, words, lines, or paragraphs, you can use the same concepts programmers use to think about code: classes, functions
https://github.com/magidc/ideavim-anyobject
ideavim ideavimrc intellij intellij-plugin jetbrains jetbrains-plugin neovim vim
Last synced: 3 months ago
JSON representation
Adds useful text objects to improve your productivity on JetBrains IDEs. Text objects provide a more natural way to tell the editor what to edit, select or jump. Instead of working with characters, words, lines, or paragraphs, you can use the same concepts programmers use to think about code: classes, functions
- Host: GitHub
- URL: https://github.com/magidc/ideavim-anyobject
- Owner: magidc
- License: mit
- Created: 2025-08-29T21:06:59.000Z (10 months ago)
- Default Branch: release
- Last Pushed: 2026-01-12T00:37:21.000Z (5 months ago)
- Last Synced: 2026-01-12T03:06:38.277Z (5 months ago)
- Topics: ideavim, ideavimrc, intellij, intellij-plugin, jetbrains, jetbrains-plugin, neovim, vim
- Language: Kotlin
- Homepage:
- Size: 5.27 MB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Vim AnyObject
### *Edit code the way you think it*
An extension for [IdeaVim](https://github.com/JetBrains/ideavim) plugin that adds useful text objects to improve your productivity on JetBrains IDEs.
Text objects provide a more natural way to tell the editor what to edit, select or jump. Instead of working with characters, words, lines, or paragraphs, you can use the same
concepts programmers use to think about code: classes, functions, arguments, loops, comments, quotes, brackets, subwords, and more.
## Available Text Objects
| Text Object | Description | Default mapping | Count motions |
|-----------------------------------------------|-----------------------------------------------------------------------------------------|-----------------|---------------|
| [AnyArgument](#anyargument-a) | Function arguments, method parameters, and callable expressions | `a` | ✓ |
| [AnyFunction](#anyfunction-f) | Functions, methods, and procedures | `f` | x |
| [AnyLambdaOrFunction](#anyLambdaOrFunction-m) | Functions, methods, procedures, lambdas and arrow functions | `m` | x |
| [AnyClass](#anyclass-c) | Class, interface, struct, and similar type definitions | `c` | x |
| [AnyVariable](#anyvariable-v) | Field/variable declarations and assignments | `v` | x |
| [AnyLoop](#anyloop-l) | Loop statements (`for`, `while`, `do`, `repeat`, `until`, `loop`, etc.) | `l` | x |
| [AnyConditional](#anyconditional-y) | Conditional statements (`if-else`, `switch`, `try-catch`) | `y` | x |
| [AnyItem](#anyitem-i) | Items within collections, tuples, lists, or arrays | `i` | ✓ |
| [AnyArgOrItem](#anyargoritem-x) | Combines objects targeted by AnyArgument and AnyItem | `x` | ✓ |
| [AnyQuote](#anyquote-q) | Content enclosed between any type of quotes (single, double, backticks) | `q` | ✗ |
| [AnyString](#anystring-g) | String content | `g` | ✗ |
| [AnyBracket](#anybracket-o) | Content enclosed between any type of brackets (parentheses, square, curly, angle, etc.) | `o` | ✗ |
| [AnySubword](#anysubword-u) | Words nested in longer words (`camelCase`, `snake_case`, `dash-case`) | `u` | ✓ |
| [AnyDocument](#anydocument-d) | Entire document content | `d` | ✗ |
| [AnyComment](#anycomment-k) | Comments across different programming languages (`/* */`, ``, etc.) | `k` | ✗ |
| [AnyIndentBlock](#anyindentblock-n) | Code blocks based on indentation levels | `n` | ✗ |
- **Inner/Outer**: All text objects support both `i` (inner) and `a` (around/outer) selection modes following standard Vim conventions
- **Jump**: All text objects allow navigation using `]` (next) and `[` (previous) motions unless other mappings are specified (see [Customization](#customization))
- **Count motions**: Text objects with count support allow selecting multiple consecutive instances. For example `d2aa` will delete two arguments including their separators
## Usage
### Deletion, Change, Visual Selection
The plugin follows standard Vim text object conventions with `i` (inner) and `a` (around) modifiers
### Jump
The plugin supports jumping to the next/previous text object using `]` (next) and `[` (previous).
A common use case is to visually select an argument `vaa`, and jump to next ones to extend the selection `]a`. This is analogous to count visual selection (i.e. `v3aa`)
### Example with argument text object (`a`)
- `dia` - Delete argument
- `daa` - Delete argument and its separator
- `d2ia` - Deletes argument and the next without including separators
- `cia` - Change argument
- `caa` - Change argument and its separator
- `c2aa` - Change argument and next one including separator
- `yia` - Yank/Copy argument
- `yaa` - Yank/Copy argument and its separator
- `via` - Visually select argument
- `v3aa` - Visually select three arguments including separator
- `v3ia` - Visually select three arguments without including separator
- `]a` - Jump to next argument
- `[a` - Jump to previous argument
## Provided text objects
### AnySubword (`u`)
Nested words in different case styles:
| Case type | Example |
|------------|-----------|
| Camel case | `fooBar` |
| Snake case | `foo_bar` |
| Dash case | `foo-bar` |
### AnyQuote (`q`)
Content enclosed between any type of quotes:
| Quote Type | Example |
|---------------|--------------|
| Single quotes | `'text'` |
| Double quotes | `"text"` |
| Backticks | `` `text` `` |
### AnyBracket (`o`)
Content enclosed between any type of brackets:
| Bracket Type | Example | Description |
|-------------------|-----------|--------------------------|
| Parentheses | `(text)` | Function calls, grouping |
| Square brackets | `[text]` | Arrays, indexing |
| Curly braces | `{text}` | Objects, code blocks |
| Angle brackets | `` | Generics |
| HTML/XML brackets | `` | HTML/XML tags, generics |
### AnyDocument (`d`)
Entire document content.
### AnyComment (`k`)
Comments across different programming languages:
| Comment Type | Languages | Example |
|----------------|-----------------------------------------------------------------------------------------|------------------------|
| `/* */`, `//` | C, C++, Java, C#, JavaScript, TypeScript, Kotlin, Scala, Swift, Go, Rust, PHP, CSS, SQL | `/* comment */` |
| `/** */` | Java (Javadoc), Rust (doc comments) | `/** documentation */` |
| `` | HTML, XML, XHTML, Markdown | `` |
| `""" """`, `#` | Python (docstrings) | `"""comment"""` |
| `''' '''` | Python (docstrings) | `'''comment'''` |
| `--[[ ]]` | Lua | `--[[ comment ]]` |
| `--[=[ ]=]` | Lua (custom delimiters) | `--[=[ comment ]=]` |
| `#'` to `'` | R (roxygen comments) | `#' comment '` |
### AnyString (`g`)
String data to assign to a variable or field.
- **Inner selection (`ig`)**: Selects only the string content
- **Outer selection (`ag`)**: Selects the entire string including quotes and leading formatting symbols
### AnyItem (`i`)
Items within collections, tuples, lists, or arrays:
| Structure Type | Example |
|----------------|-------------------------|
| Arrays | `[item1, item2, item3]` |
| List literals | `(item1, item2, item3)` |
- **Inner selection (`ii`)**: Selects only the item itself
- **Outer selection (`ai`)**: Selects the entire item including the separator and the item itself
**Multiple outer selections are supported**. For example `d2ai` will delete the current item and the next one including separator
### AnyArgument (`a`)
Function arguments, method parameters, and callable expressions.
- **Inner selection (`ia`)**: Selects only the argument itself
- **Outer selection (`ia`)**: Selects the entire argument including the separator and the argument itself
**Multiple outer selections are supported**. For example `d2aa` will delete the current argument and the next one including separator
### AnyArgOrItem (`x`)
Combines objects targeted by AnyArgument and AnyItem.
Selects any function argument, method parameter, callable expression, or collection items.
### AnyVariable (`v`)
Field/variable declarations and assignments.
- **Inner selection (`iv`)**: Selects only the value assigned to the field/variable if any
- **Outer selection (`av`)**: Selects the entire field/variable declaration
### AnyFunction (`f`)
Functions, methods, and procedures.
- **Inner selection (`if`)**: Selects only the function body
- **Outer selection (`af`)**: Selects the entire function including the function name, decorators, and the body
### AnyLambdaOrFunction (`m`)
Extends AnyFunction to include lambda or arrow functions.
### AnyClass (`c`)
Class, interface, struct, and similar type definitions.
- **Inner selection (`ic`)**: Selects only the class body
- **Outer selection (`ac`)**: Selects the entire class including the name, decorators, and the body
### AnyLoop (`l`)
Loop statements and iterative constructs like `for`, `foreach`, `while`, `until`, `do`, `repeat`, `until`, `loop`, `for`, `foreach`, `while`, `until`, `do`, `repeat`, `until`,
`loop`.
- **Inner Selection (`il`)**: Selects only the statements within the current loop/iteration where the cursor is positioned
- **Outer Selection (`al`)**: Selects the entire loop construct including all branches and control keywords
### AnyConditional (`y`)
Conditional statements and expressions like `if-else`, `switch` or `try-catch` statements.
- **Inner Selection (`iy`)**: Selects only the statements within the current branch/case where the cursor is positioned
- **Outer Selection (`ay`)**: Selects the entire conditional construct including all branches and control keywords
### AnyIndentBlock (`n`)
Code blocks based on indentation levels. This is particularly useful for indentation-based languages like Python, YAML, or Haskell, but also works with brace-based languages to
select logical indentation blocks.
- **Inner Selection (`in`)**: Selects from first to last character of the current block
- **Outer Selection (`an`)**: Selects entire lines of the current block
## Configuration
Configure which transformation groups to enable in your `.ideavimrc`:
```vimscript
" Activate plugin
set anyobject
```
### Customization
Don't want to use all the provided text objects? Specify which ones to enable using `anyobject_included` variable in your `.ideavimrc`:
```vimscript
let g:anyobject_included = "anyDocument,anyFunction"
```
If you prefer to specify which ones to exclude, use the `anyobject_excluded` variable instead:
```vimscript
let g:anyobject_excluded = "anyDocument,anyFunction"
```
You can also customize the mappings by adding the following to your `.ideavimrc`. For example:
```vimscript
" Use 'm' instead of default 'f' for any function text object
let g:anyobject_map_anyfunction = "m"
" Use 's' instead of default 'd' for any document text object
let g:anyobject_map_anydocument = "s"
```
In case of mapping conflicts, the custom mappings will take precedence and invalidate any other handler using the same mapping.
Jump motion can be also customized:
```vimscript
" Use '<' instead of default '[' for jumping to the previous text object
let g:anyobject_map_jump_prev = "<"
" Use '>' instead of default ']' for jumping to the next text object
let g:anyobject_map_jump_next = ">"
```
### Some examples
#### AnyQuote
- `diq` - Delete text inside any quotes
- `daq` - Delete text including the quotes
- `ciq` - Change text inside any quotes
- `yiq` - Yank text inside any quotes
- `viq` - Visually select text inside any quotes
#### AnyBracket
- `dio` - Delete text inside any brackets
- `dao` - Delete text including the brackets
- `cio` - Change text inside any brackets
- `yio` - Yank text inside any brackets
- `vio` - Visually select text inside any brackets
#### AnyArgument
- `dia` - Delete argument
- `daa` - Delete argument and its separator
- `d2ia` - Deletes argument and the next one
- `cia` - Change argument
- `caa` - Change argument and its separator
- `c2aa` - Change argument and next one including separator
- `yia` - Yank/Copy argument
- `yaa` - Yank/Copy argument and its separator
- `via` - Visually select argument
- `v3ia` - Visually select three arguments
- `]a` - Jump to next argument
- `[a` - Jump to previous argument
## Installation
### Jetbrains Marketplace
1. Install the plugin from the IntelliJ IDEA Plugin Marketplace
2. Ensure you have the IdeaVim plugin installed and enabled
3. Activate the plugin in your `.ideavimrc`
4. Restart IntelliJ IDEA
### Manual Installation
1. Download the [latest release](https://github.com/magidc/ideavim-anyobject/releases)
2. Install manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
## Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Acknowledgments
- Built on top of [IdeaVim](https://github.com/JetBrains/ideavim) plugin
- Inspired by the super useful Neovim plugin [nvim-various-textobjs](https://github.com/chrisgrieser/nvim-various-textobjs)
- Vim community for inspiring powerful text object concepts