Chapter 26.Table of ContentsCheatsheet

Bonus 1: The Entire and Arguments Text Objects

In addition to the built-in Vim text objects the VSCodeVim extension enhances the suite of text objects with two additional ones:

  1. The entire text-object represents the entire content of a buffer
  2. The arguments text-object represents arguments within a function or method in the context of a programming language

With these two new additions the vocabulary of VSCodeVim extends to the entirety of a buffer and arguments within a function and allows you to use all the existing Vim operators on these new tet objects.

The Entire Text Object

Following the pattern used in common text-objects VSCodeVim adds:

  • ae that represents the whole content of a buffer (all entire buffer)
  • ie that represents the whole content of the buffer without the surrounding whitespace (inside entire buffer)

So that you can:

  • dae delete (or cut) the whole buffer
  • yie yank (copy) the whole buffer except surrounding whitespace
  • =ae format the whole buffer
  • >ae increase indendation in the whole buffer

The Arguments Text Object

In a similar way, and inspired by the great targets.vim Vim plugin, we can use the argument text-objects to interact with function and method arguments:

  • aa represents arguments including separators
  • ia represents arguments excluding separators

Taking advantage of this text object we can now:

  • daa delete the current argument from a function signature
  • cia change the current argument for something else

This particular plugin can be configured to work with your language of choice using these settings:

Configuration key Description Example
vim.argumentObjectOpeningDelimiters list of opening delimiters ["(", "["]
vim.argumentObjectClosingDelimiters list of closing delimiters [")", "]"]
vim.argumentObjectSeparators list of separators [","]

Jaime González García

Written by Jaime González García , dad, husband, software engineer, ux designer, amateur pixel artist, tinkerer and master of the arcane arts. You can also find him on Twitter jabbering about random stuff.Jaime González García