Elixir Cursor Rules

Learn about cursor rules specific to Elixir development.

Elixir-Specific Rules

Cursor rules in Elixir enhance your coding experience by providing smart navigation and manipulation features tailored for Elixir's functional programming paradigm and unique syntax features.

Code Navigation

  • Jump between function clauses and pattern matching blocks
  • Navigate through pipe operators (|>) efficiently
  • Quick access to module attributes and directives
  • Smart navigation between macro definitions and expansions

Smart Selection

  • Select function heads and guards
  • Expand selection to include pattern matching expressions
  • Smart module attribute and behavior selection
  • Intelligent pipe chain selection

Code Manipulation

  • Quick module function insertion
  • Automated pattern matching clause handling
  • Module attribute and behavior management
  • Pipe operator chain manipulation

Best Practices

  • Use pattern-matching aware navigation
  • Leverage pipe operator-specific cursor movements
  • Utilize macro-aware selection and navigation

Examples

# Navigate between function clauses
def process_data(data) when is_list(data) do
  data
  |> Enum.map(&transform/1)
  |> Enum.filter(&valid?/1)
end

def process_data(data) when is_map(data) do
  data
  |> Map.values()
  |> process_data()
end

# Smart selection of pipe operators
def transform_data(input) do
  input
  |> String.downcase()
  |> String.split()
  |> Enum.map(&String.capitalize/1)
  |> Enum.join(" ")
end

# Module attribute and behavior navigation
@behaviour GenServer

@impl true
def handle_call({:get, key}, _from, state) do
  {:reply, Map.get(state, key), state}
end

Configuration

Customize Elixir-specific cursor rules in your settings:

{
  "elixir.cursorRules": {
    "patternMatchingNavigation": true,
    "pipeOperatorHandling": true,
    "macroExpansionSupport": true
  }
}