Skip to content

jphalip/ideavim-functiontextobj

Repository files navigation

FunctionTextObj (IdeaVim extension)

An extension for IdeaVim that adds text objects for manipulating functions/methods in your code. Similar to how iw operates on words or i" operates on quoted strings, this plugin provides if and af to operate on functions.

Features

  • if - "inner function" - selects the function body (excluding braces)
  • af - "around function" - selects the entire function (including braces and signature)

These text objects work with all Vim operators and in visual mode:

dif  - delete the function body
caf  - change the entire function
vif  - visually select the function body
yaf  - yank (copy) the entire function

Supported Languages

This extension supports function/method selection in the following languages using the Jetbrains language plugins:

Installation

  1. Install IdeaVim if you haven't already
  2. Install this plugin:
    • In IntelliJ IDEA: Settings/Preferences → Plugins → Marketplace → Search for "Vim FunctionTextObj"
    • Or download from JetBrains Marketplace
  3. Add set functiontextobj to your ~/.ideavimrc file, then run :source ~/.ideavimrc or restart the IDE.

Customization

Don't like the default f mapping? You can remap the text objects in your .ideavimrc:

" Use 'm' instead
omap im <Plug>InnerFunction
omap am <Plug>OuterFunction
vmap im <Plug>InnerFunction
vmap am <Plug>OuterFunction

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages