Skip to content

mini-lite/vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 

Repository files navigation

Vim

vim emulation for Pragtical and Lite XL editors Author: S.Ghamri

Inspiration

This plugin is inspired by Evil (Emacs) and aims to be as faithful as possible to Vim’s modal editing experience, while adapting to the Lite XL and Pragtical environments. The goal is to provide a robust, extensible, and familiar workflow for users who love Vim’s efficiency and philosophy.

Features

  • Modal editing: normal, insert, visual, visual-line, command, delete, o-pending
  • Full keymap support for normal and visual modes, including remapping (hjkl, etc.)
  • Visual selection, line selection, and motion-based operations
  • Operator-pending mode for advanced text manipulation
  • Customizable ex commands (e.g., :w, :q, :bd, :path)
  • Search and replace with / and ? (forward and backward)
  • Register support for yanking, putting, and deleting
  • System clipboard integration (unnamedplus)
  • Flashing and highlighting for feedback (e.g., yank, put)
  • Centering selection in view after motions
  • Custom command registration and extensibility
  • Status bar integration with command-line plugin (prompt, messaging, confirm)
  • Undo/redo, repeat last change, and advanced motions (word, line, bracket, etc.)
  • Bracket matching (%) and text object support (iw, aw, etc.)
  • Customizable config (flash color, unified search, etc.)
  • Key flow and caret adapts to text size and mode
  • Integration with Pragtical’s command-line for ex commands and messaging
  • Confirm prompt (y/n) for destructive actions
  • Designed to keep code under 1000 lines for maintainability

Functionality Overview

  • The plugin sets up Vim modes and state tracking, including registers, command buffer, search query, operators, motions, and keymaps.
  • It overrides core event handling to intercept keypresses and text input, enabling modal behavior and remapping.
  • Operators (move, select, line_select, delete, yank) are defined to work with motions and text objects, supporting complex editing workflows.
  • Motions include character, word, line, and bracket navigation, with support for custom text objects and translations.
  • Ex commands are registered and executed via the command-line plugin, with support for custom user commands and suggestions.
  • Visual feedback is provided via flashing, highlighting, and status bar messages.
  • The plugin integrates tightly with the command-line plugin, using decorated instances for command, search, and confirm prompts.
  • Undo, redo, and repeat are supported, with plans for further enhancements (e.g., dot-repeat, advanced registers).
  • The plugin is extensible: users can add custom commands, keymaps, and behaviors.

Usage and Keymaps

  • Normal mode: hjkl for movement, x/X/s/S for deletion, y for yank, p/P for put, o/O for new lines, u for undo, : for command, / for search, ? for reverse search, v/V for visual modes, * for search word under cursor, n/N for next/prev search, % for bracket match, etc.
  • Visual mode: v/V to enter, motions to select, operators to act on selection, p/P for put, * for search selection, # for yank/delete selection.
  • Operator-pending: after d/y/c, wait for motion or text object.
  • Command-line: : for ex commands, / and ? for search, confirm prompt for y/n actions.
  • Remapping: arrow keys to hjkl, customizable via config.

Extensibility

  • Users can register custom ex commands via vim.register_command(cmd, action, desc)
  • Keymaps and motions can be extended or remapped
  • Status bar messaging and prompts are fully customizable
  • Designed for easy integration with other plugins and workflows

Known Issues & TODOs

– BUGS ----------------------------------------------------------------------

– FIX: vi { } go confused by other opening brackets – FIX: arrage state variables like mod_keys – FIX: clean i and a, maybe they can become translations since same arguments

– FEATURES ------------------------------------------------------------------

– TODO: make text color change when flashing – TODO: <Medium> impelement insert count + “i or a” + input then <esc> – TODO: clean code and arragne to ease moving forward – TODO: implement visual block – TODO: implement jumps – TODO: clean code before becoming unmaintable (KISS) – TODO: implement: r replace single character, the next “key” goes in place of selected char – TODO: implement: ~ toggle case of the current char – TODO: add second count to implement something like 3d2k – TODO: follow delete() naming and reduce noise adopt short naming – TODO: add mechanisms to use registers, yank and put can accept register argument – TODO: it must be under 1000 lines of code – TODO: shift is still selecting in normal disable it, either disable this or support it – TODO: normal mode is working outside doc view, to benifit from : command line outside – TODO: “space” can be used as leader or adapt if user want space as leader – TODO: let user extend commands – TODO: add disable vim config, to allow user enable or disable it – TODO: how to test vim, it is starting to be big, minor change is going to effect other areas – TODO: enable only overrides only when vim plugin is loaded

– DONE ----------------------------------------------------------------------- – DONE: <command line> enhance command line messaging system with FiFo with time – DONE: make control robust, handle input gets lost sometimes – DONE: implement “<” – DONE: implemented “>” – DONE: tab = space, vim uses both tab and space – DONE: enhance how vim pluging overrides keymappings and add them (need to register known keymaps) – DONE: how keymaps are regisered in this plugin – DONE: Ctrl-r redo – DONE: vi{ includes last } if first char on line – DONE: put a whole file makes the last line putted first only when put reaches end of file – DONE: caret width – DONE: update README – DONE: visual line from down to up when canceled stay at new location – DONE: How do we add vim ex commands ?? – DONE: visual line when reaches the end of a file spit and error – DONE: enable x and X and s and S a single character deletion – DONE: enable f and F motion to jump to next character (translation) – DONE: implement % to match brackets – DONE: put does not make selection at the end in multiple lines – DONE: yy yank a line – DONE: put can handle clipboard , add a config that allows vim system to use clipboard – DONE: copy path of the current file in clipboard – DONE: start pomping a command parser, user can add custom commands – DONE: delete multiple lines throws selection below we should stay on top – DONE: check unused variables, enable lsp and reformat code – DONE: we are moving to center even if visible when clicking $ – DONE: add default operators to vim operators – DONE: add a config to use only / and ? to search entire file – DONE: clean yank paths – - normalize select, delete, put, move. – - they must use same coordinates, same clear logic for the future. – DONE: cursor hides after putting multiple lines – DONE: enhance put() – - dd does does yank but put does not recognize is full line to yank below – - put adds one character when yanked is visual line – DONE: search returns a selection we should be able to yank directly (normal + 1 selection = yank possible) – DONE: delete what is selected, we need a mode o-pending where motion for operation – DONE: refactor to simplify motions code – DONE: start adding important navigations – DONE: let’s escape pass through – DONE: reverse search is not working – DONE: implement start * – DONE: now turn logic into a state machine to turn the emulation realistic – handle_input is the state_machine run logic – rely of delete_to, select_to and move_to otherwise we define our own – DONE: caret is adapting to text size – DONE: correct visual j k behavior – DONE: motions can be function that accept text objects – DONE: deleting a line does not leave an empty line behind – DONE: track vim commands using a state – DONE: puting also flashes and yanking flashes in all situations – DONE: p and P insert even when empty. when adding a new line go selection to beginning of that line – DONE: insert next line o and O – DONE: fix the put in the next line no added empty line we must ensure that only one \n exists – DONE: any delete will go to register to be put – DONE: key flow in insert is not smooth, is typing smooth now ??? – DONE: vim is overriding arrows in normal mode – DONE: dd delete – DONE: a bug we need to click ddd to get dd – DONE: copy is adding new lines – DONE: enhance visual line mode – DONE: correct cursor on selection problem, override all doc view related functions – DONE: yanking shows flash of region change color to intense – DONE: visual select does not start from current char – DONE: enable yank and put – DONE: show message notifying the change of state – DONE: give the command line a name – DONE: change caret in normal vim mode – DONE: vim command-line – DONE: modal editing – DONE: let user extend keymaps


Disclaimer

This plugin is a work in progress and has not been exhaustively tested. If you encounter any issues, please open an issue and the author will address it.

License

MIT

About

vim emulation for pragtical and lite xl editor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages