Raxol.Navigation.Vim (Raxol v2.0.1)

View Source

VIM-style navigation for terminal buffers.

Provides familiar VIM keybindings for buffer navigation including:

  • Basic movement (h, j, k, l)
  • Jump commands (gg, G, 0, $)
  • Word movement (w, b, e)
  • Search (/, ?, n, N)
  • Visual mode selection

Example

state = Vim.new(buffer)
{:ok, new_state} = Vim.handle_key("j", state)  # Move down
{:ok, new_state} = Vim.handle_key("w", state)  # Next word
{:ok, new_state} = Vim.handle_key("/", state)  # Start search

Configuration

config = %{
  wrap_horizontal: true,
  wrap_vertical: false,
  word_separators: " .,;:!?",
  search_incremental: true
}

state = Vim.new(buffer, config)

Summary

Functions

Get the current visual selection range.

Handle a key press and update navigation state.

Create a new VIM navigation state.

Types

mode()

@type mode() :: :normal | :search | :visual

position()

@type position() :: {non_neg_integer(), non_neg_integer()}

search_direction()

@type search_direction() :: :forward | :backward

t()

@type t() :: %Raxol.Navigation.Vim{
  buffer: Raxol.Core.Buffer.t(),
  command_buffer: String.t(),
  config: map(),
  cursor: position(),
  mode: mode(),
  search_direction: search_direction() | nil,
  search_index: non_neg_integer(),
  search_matches: [position()],
  search_pattern: String.t() | nil,
  visual_start: position() | nil
}

Functions

get_selection(arg1)

@spec get_selection(t()) :: {position(), position()} | nil

Get the current visual selection range.

handle_key(key, state)

@spec handle_key(String.t(), t()) :: {:ok, t()} | {:error, String.t()}

Handle a key press and update navigation state.

new(buffer, config \\ %{})

@spec new(Raxol.Core.Buffer.t(), map()) :: t()

Create a new VIM navigation state.