# Interactive Line Editing CJ's Shell uses the [isocline](https://github.com/cadenfinley/isocline) line editor library to provide a powerful and feature-rich interactive editing experience. This document details all editing features currently available in cjsh. ## Overview Isocline is a modern, pure C line editing library that provides advanced terminal interaction capabilities. CJ's Shell leverages and extends isocline to offer: - Multiline editing with intelligent indentation - Real-time syntax highlighting - Context-aware tab completion - Inline hints and preview suggestions - Customizable key bindings - Mouse-aware cursor movement and menu selection - Line numbering for multiline input - Optional visible markers for whitespace characters - History search and management - Brace matching and auto-insertion - Spell correction - Fish-style abbreviations (automatic expansion on word boundaries) All of these features can be configured through the `cjshopt` command or in your `~/.cjshrc` configuration file. ## Core Editing Features ### Multiline Input CJ's Shell supports seamless multiline input for complex commands, heredocs, and incomplete statements. **Features:** - Automatic continuation when lines are incomplete - Smart indentation that aligns with the initial prompt - Line numbers for easy navigation - Both absolute and relative line numbering modes **Configuration:** ```bash # Enable/disable multiline input (enabled by default) cjshopt multiline on|off|status # Enable/disable automatic indentation (enabled by default) cjshopt multiline-indent on|off|status # Configure how many prompt lines are shown before typing (default: 1) cjshopt multiline-start-lines # Limit visible multiline input rows (default: 15) cjshopt multiline-max-lines # Configure the multiline cursor margin (default: 3) cjshopt multiline-bottom-lines ``` When a command exceeds the viewport limit, the visible rows scroll with the cursor while the full command remains available for editing and submission. Completion menus and other helper rows are laid out separately below the input viewport. The symmetric cursor margin keeps the viewport fixed while the cursor moves within it, uses only rows that exist in the command, and never pads the display with blank lines. **Multiline Detection:** CJ's Shell automatically enters multiline mode when: - A line ends with a backslash (`\`) - Quotes are unclosed (`"`, `'`, or backticks) - Control structures are incomplete (`if`, `while`, `for`, `case`, etc.) - Heredocs are being entered (`<<`, `<<-`) - Brackets/braces/parentheses are unclosed ### Line Numbers When in multiline mode, line numbers help track your position in the input. **Modes:** - **Absolute numbering**: Shows actual line numbers (1, 2, 3, ...) - **Relative numbering**: Shows distance from current line (0 for current, ±N for others) **Configuration:** ```bash # Enable absolute line numbers (default) cjshopt line-numbers on cjshopt line-numbers absolute # Enable relative line numbers cjshopt line-numbers relative # Disable line numbers cjshopt line-numbers off # Check current status cjshopt line-numbers status ``` > **Tip:** Custom continuation prompts normally suppress multiline line numbers. Restore them > by running `cjshopt line-numbers-continuation on` (or calling > `ic_enable_line_numbers_with_continuation_prompt(true)` from your startup scripts) before the > editor initializes. > > Multi-line prompts that render banners or status lines can swap the final PS1 row with the > numeric gutter so that every editable line begins with `1|`, `2|`, etc. Enable this behavior with: > > ```bash > cjshopt line-numbers-replace-prompt on|off|status > ``` > > The replacement only applies when line numbers are visible (and, if `PS2` is set, when > `cjshopt line-numbers-continuation on` is active). **Current Line Highlighting:** The line containing the cursor can be highlighted differently: ```bash # Enable/disable current line number highlighting (enabled by default) cjshopt current-line-number-highlight on|off|status ``` The line number styles can be customized: - `ic-linenumbers`: Style for regular line numbers - `ic-linenumber-current`: Style for the current line number ### Visible Whitespace Markers You can visualize whitespace characters while editing to spot stray spaces or indentation issues. When enabled, spaces are rendered using a subtle middle-dot marker. **Configuration:** ```bash # Show or hide visible whitespace markers (disabled by default) cjshopt visible-whitespace on|off|status ``` Pair this option with custom styling via `cjshopt style_def ic-whitespace-char "