Skip to content
Cursor & Selection
step 1/5

Reading — step 1 of 5

Read

~1 min readDisplay & Input

Cursor & Selection

A cursor: a position in the buffer.

A selection: a range (start, end). Cursor is at one end (the "active" end).

python

Movement:

  • Left/right arrow: pos -= 1 / += 1, clear selection_start.
  • Shift+arrow: pos -= 1 / += 1, KEEP selection_start.
  • Ctrl+arrow: word boundaries.
  • Home/End: line start/end.
  • Page up/down: viewport-sized jumps.

Multi-cursor:

  • Multiple Cursor instances simultaneously.
  • Each tracks its own pos + selection.
  • Edits applied to all simultaneously.
  • Sublime Text popularized.
  • Implementation: list of cursors; sort by pos for edit application.
python

Visual modes (Vim):

  • Character mode: select by character.
  • Line mode: select whole lines.
  • Block mode: rectangular column selection.
  • Different operations apply differently.

Cursor blink:

  • Visual feedback.
  • Toggle every 500ms when idle.
  • Stop blinking during edit (looks better).

Mouse interaction:

  • Click: place cursor.
  • Click + drag: select range.
  • Double-click: select word.
  • Triple-click: select line.
  • Shift+click: extend selection.
  • Ctrl+click: add cursor (multi-cursor).

Word boundaries:

  • Default: alphanumeric vs non-alphanumeric.
  • Cursor jumps to next word boundary.
  • Configurable (camelCase splitting, etc.).

Bracket matching:

  • When cursor on (, highlight matching ).
  • Stack-based scan from cursor.
  • Editor extension feature.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…

Cursor & Selection — Build a Text Editor