Table of Contents
Lued
lua-based text editor
Description
Lued is an extensible, terminal-based text editor written in Lua and C.
Contact
<jwrr.com@gmail.com> Vist jwrr.com for more examples.Download
- Source code is available at https://github.com/jwrr/lued.git
- Precompiled binaries are available in the download folder
Basic Operations Work as Expected
- Open a file with
lued filename.txt
and just start typing... - Arrow keys, Delete, Backspace, PgUp, PgDnwork as expected.
- Homeand Endgo to the beginning and end of line, respectively.
- Ctrl+Ssaves the file.
- Ctrl+Aselects all of the text in the file.
- Ctrl+Ffinds a string.
- Ctrl+Hreplaces a string.
- Ctrl+Zand Ctrl+Zundo and redo, repectively, as expected.
- Ctrl+Oopens an existing file.
- Ctrl+Nopens a new file.
- Ctrl+C, Ctrl+Xand Ctrl+Vcopy, cut and paste.
- Ctrl+Qquits the editor and Ctrl+Wcloses the file (when editing multiple files).
Ctrl, Alt and Esc
- When possible Lued uses the CtrlKeybinding from Word, Sublime or VS Code.
- If an exact Keybinding is not available then a similar AltKeystroke sequence is used.
- Note: Pressing and releasing Escand then pressing a key is equivalent to simultaneously pressing Altand the key. Some keystrokes may be more comfortable with Esc, while others may be easier with Alt. This behavior is a feature of the terminal and is not unique to Lued.
Working Multiple Files
From the command line you can open one or more files,lued .txt
. Each file
is contained in a tab. Once in lued, you can open, close, create and select
files with the following commands.
- Ctrl+Oopens another file.
- Alt+ttlets you select from a list of open tabs/files.
- Alt+TTtoggles between the last two tabs.
- Alt+=changes to the next tab.
- Alt++changes to the previous tab.
- Ctrl+Ncreates a new file.
- Alt+wcloses the current file..
Moving Around
- The arrow keys move the cursor as expected, move left, right, up and down.
- Alt+wwjumps to the next word. If available, Shift+Right_Arrowalso goes to the next word.
- Alt+WWjumps to the previous word.
If available, Shift+Left_Arrowalso goes to the previous word.
- Alt+wejumps to the end of the line.
If available, Endalso goes to the end of the line - Alt+wqjumps to the start of the line.
If available, Homealso jumps to the start of the line.
- Alt+ppmoves down a partial page (the partial page size is configurable).
If available, Shift+DownArrow also moves down a partial page. - `k+PP moves up a partial page.
If available, Shift+UpArrow also moves up a partial page.
- Alt+bbmoves to the bottom, last line. If you're already at the bottom then it takes you to the top, first line, of the file..
- >and <move the cursor left in a binary search manner, cutting the distance in half, with each keypress. It takes some getting used to, but it's efficient.
Select, Copy, Cut, Delete and Paste
- Alt+kselects the current word.
- Alt+ccopies selected text to the paste buffer.
- Alt+xcuts selected text to the paste buffer.
- Alt+vwrites the paste buffer into the text.
- Alt+edeletes to the end of word. If the cursor is over whitespace then it deletes the whitespace up to the start of the next word.
- Alt+dcuts an entire line into the paste buffer. Continue hitting Alt+dadds each deleted line to the paste buffer, so the paste buffer will contain multiple lines. You can then Alt+vto restore the text, move to another location and Alt+vagain, to duplicate the text.
- Alt+.starts selecting text. Move the cursor to the end of the selection and press Alt+cor Alt+xto copy or cut the selection into the paste buffer. If you start typing when a region is selected, the region will be deleted and replaced with the typing. Press Alt+.to abort the selection.
Find and Replace
- Alt+fis the forward find command and presents a dialog to enter a search string. Previous searches can be accessed quickly using the up arrow key.
- Alt+Fis the reverse find command.
- Alt+lis the find next command. If text is selected then the selected text will be searched for.
- Alt+jfinds the previous occurrence of the search string.
- Alt+ris the find and replace command.
- Alt+Sallsearches all tabs.
Comments
- Alt+CCcomments out the line and advances to the next line
- Alt+CSsets the comment to a custom string value.
Remove All Trailing Spaces
- Trailing whitespace is highlighted.
- Alt+Ratsremoves all trailing spaces. Esc+Ratsis equivalent
Mouse
- Try the Scroll Wheel... It should work
- Try Mouse select... It should work too Left Mouse Button to select, Middle Mouse Button to paste at cursor. Or... Left Mouse Button to select, Right Mouse Button to copy/paste to/from system buffer.
Installation
- git clone https://github.com/jwrr/lued.git
- cd lued
- make install make uses wget to download Lua 5.2.4 from https://www.lua.org/ftp make clones the carr repo from https://github.com/jwrr/carr carr provides support for large, dynamic arrays written in the C programming language. make compiles the source code make creates and populates ~/.lued make prompts to add lued to path
- ./lued TreasureIsland.txt ## courtesy of Project Guttenberg
Customize Keyboard Bindings
You can easily modify the keyboard bindings. The Lua file lued_bindings.lua contains the keyboard bindings.Extending Lued
You can write new Lued features and store them in the .lued/plugin directory. Files in this directory are automatically read at startup. lued_lib.lua contains the default Lued commands an provides a reference for new features.Terminal Work-arounds
- Alt+V - Gnome Terminal provides many keyboard shortcuts (https://help.gnome.org/users/gnome-terminal/stable/adv-keyboard-shortcuts.html.en). Sometimes the Gnome bindings conflict with LuEd bindings. For example, Alt+Vopens the Gnome Terminal View Menu. To disable Gnome's Alt+Vbehavior do the following: Edit > Keyboard Shortcuts..., and then unselect "Enable menu access keys". If you want to keep the Gnome behavior, Lued provides an alternative keyboard binding, Ctrl+V' instead of Alt+V.
- Ctrl+S - Terminals usually stop when Ctrl+S (XOFF) is pressed and remain suspended until Ctrl+Q (XON) is presed. This behavior may be confusing and a user may think the application is hung. The KDE Konsole terminal attempts to help by printing a warning message "Output has been suspended by pressing Ctrl+S. Press Ctrl+Q to resume". LuEd, and other text editors, use the stty command to disable the Ctrl+S (XOFF) and Ctrl+Q (XON) behavior. Unfortunately, older versions of Konsole have a bug that incorrectly shows the error message even when Ctrl+S (XOFF) is disabled. * Lued provides an alternative keyboard binding, Alt+s'Enter,to work around this Konsole bug.
TBD
- Indent Selection
- Block Select, Cut, Copy, Move
- Split screen
- Document API for plugins
- Syntax Highlighting
Lued Key Bindings
Control Key Commands
Ctrl+_at_ Called when resuming from Ctrl+Z (fg at shell prompt) Ctrl+Q Quit or Exit. Similar to Sublime Ctrl-Q. Ctrl+W Close window or tab. Similar to Sublime Ctrl-W. Ctrl+E Spare Ctrl+R Spare Ctrl+T Spare Ctrl+Y Redo (undo undo). Similar to Sublime Ctrl+Y Ctrl+U Spare Ctrl+I Do Not Use. Terminal interprets as Tab
keyCtrl+O Open File. Similar to Word Ctrl+O Ctrl+P Open File from partial name. Similar to Sublime Ctrl+P Ctrl+A Select All (Entire File). Similar to Sublime Ctrl+A. Ctrl+S Save File. Similar to Sublime Ctrl+S. Ctrl+D Select Word under cursor. Similar to Sublime Ctrl+D Ctrl+F Find. Similar to Sublime Ctrl+F. If text is selected the find selected text (Similar to Sublime Ctrl+F3). Ctrl+G Goto Line Number. Similar to Sublime Ctrl+G Ctrl+H Find and Replace. Similar to Sublime Ctrl+H. Ctrl+J Do Not Use. Same as Ctrl+K Spare Ctrl+L Select entire line. Similar to Sublime Ctrl+L Ctrl+Z Undo. Similar to Sublime Ctrl+Z Ctrl+X Cut. Similar to Word and Sublime Shift+Delete Ctrl+C Copy. Similar to Word Ctrl+V Paste. Similar to Word Ctrl+B Spare. Ctrl+N Create New File. Similar to Word. Ctrl+M Do Not Use. File Tab Commands
Alt+tt Select file tab from list of open files. Alt+TT Toggle to previous file tab Alt+_equal_ Change to next file tab. Similar to Sublime next_view Ctrl+Tab. Alt+_plus_ Change to previous file tab. Similar to Sublime prev_view Ctrl+Shift+Tab. Movement Commands
Alt+bb Goto bottom of file Alt+BB Goto top of file Alt+bd line sinks to bottom of file. Similar to sublime Ctrl+Shift+Down Alt+bu line floats to top of file. Similar to sublime Ctrl+Shift+Up Alt+cb ctag back Alt+cf ctag forward in stack Alt+ct ctag jump. Similar Sublime Ctrl+R Alt+ch ctag history Alt+cx ctag delete history Comment Commands
Alt+cc Comment out line. Similar to Sublime Ctrl+slash. Alt+cs Comment Set. Change start of comment string Alt+cu Uncomment selected lines. Copy Commands
Alt+ce copy current pos to eol Alt+cq copy sol to current pos Alt+cw Copy Word Alt+dd Duplicate line. Similar to Sublime Ctrl+Shift+D Find and Replace Commands
Alt+fa Similar to Sublime Ctrl+Shift+F. search all open files for match Alt+fb find back. return to position before find operation. Alt+ff Similar to Sublime F3. Find next occurrence of search text. Alt+FF Similar to Sublime Shift+F3. Find previous occurrence. Alt+fc toggle find case sensitive Alt+fw toggle find whole word Alt+hh Replace again Alt+_minus_ Jump back to previous position before Find. Similar to Sublime jump_back. Alt+_ Jump forward to next position in jump stack. Similar to Sublime jump_forward. Indent and Align Commands
Alt+ii Indentselected lines one space. Alt+ir Re-indentselected region per defined indent size. Alt+is Setindent size. Alt+aa Align char on current line with previous line Alt+af Align first char on next line with current line. If lines selected then align all lines with first line. Center Cursor Commands
Alt+kc Similar to Sublime's CTRL+KC. vim's zz/zt. recenters cursor to top, press again and recenters to center. Case Commands
Alt+kl Similar to Sublime Ctrl+KL. Convert to Lower Case Alt+ku Similar to Sublime Ctrl+KU. Convert to Upper Case Mark Commands
Alt+ka Similar to Sublime Ctrl+KA. Select from mark to cursor (set mark with Alt+mm) Alt+kw Similar to Sublime Ctrl+KW. Delete from mark to cursor (set mark with Alt+mm) Alt+mm Similar to Sublime Ctrl+K+space. Set Mark Alt+mp Goto previous mark Alt+mn Goto next mark in stack Insert Line Before / After Commands
Alt+ll similar to vi's o. Similar to Sublime Ctrl+Enter Alt+lk similar to vi's O. Similar to Sublime Ctrl+Shift+Enter Page Up / Down Commands
Alt+pp Similar to Sublime , move down one page Alt+PP Similar to Sublime , move up one page Remove Tabs and Spaces
Alt+ralt Replace all leading tabs with spaces at start of line Alt+rats Remove all trailing spaces at end of line Alt+ratsall Remove all trailing spaces in all files Select Commands
Alt+si Similar to Sublime Ctrl+shift+J. Select lines with the indentation. Alt+sq Select from cursor to start of line Alt+sb Select inside curly brace Alt+se Select from cursor to end of line Alt+sq Select from cursor to start of file Alt+sg Select from cursor to end of file Alt+sm Select from mark (alt+mm) to cursor. Similar to Sublime Ctrl+K Alt+ss Turn off/on selection. Similar to Sublime . Alt+sw Select Word (same as Ctrl+D). Similar to Sublime Ctrl+D Line Swap Commands
Alt+sn Swap current line with next line. Similar to Sublime Ctrl+DOWN arrow Alt+sp Swap current line with prev line. Similar to Sublime Ctrl+UP arrow Move Commands
Alt+u Move N lines up. Alt+u42 moves up 42 lines Alt+uu Move N lines up. Alt+u42 moves up 42 lines Alt+ui Unindent selection one level Alt+ww Move right one word. Similar to Sublime Ctrl+right_arrow. Alt+WW Move left one word. Similar to Sublime Ctrl+left_arrow. Alt+wq Move to Start of Line. Similar to Sublime . Alt+we Move to End of Line. Similar to Sublime . Alt+_gt_ Move right half the distance Alt+_lt_ Move left half the distance Alt+l Move N char left. Alt+l42 moves 42 char to the left Alt+r Move N char right. Alt+r42 moves 42 char to the right Delete / Cut and Paste Commands
Alt+xq Similar to Sublime Ctrl_K+ Alt+xe Similar to Sublime Ctrl+KK Alt+xm Delete from mark (alt+mm) to cursor Alt+xs Delete spaces from cursor to non-whitespace. If on non-whitespace then go to next line and do it. Alt+xw Delete word under cursor Alt+xx Similar to Sublime Ctrl+KW Alt+XX Similar to Sublime Ctrl+Backspace Alt+pl Paste line after current line Alt+pk Past line before current line Alt+z Similar to Sublime Ctrl-z. Undo. After alt-z is used, ctrl-z becomes unix suspend command. Configuration Settings Commands
Alt+_period_c Toggle Ctrl+C between Cut and Kill Process Alt+_period_ind Turn auto-indent on/off Alt+_period_edi Change from Lua mode to Edit mode. You almost always want to be in edit mode. Alt+_period_lua Toggle to Lua mode to enter lua commands. Rarely used. Alt+_period_mlt Set minimum lines to from top of page to cursor Alt+_period_mlb Set minimum lines from cursor to bottom of page Alt+_period_ps Change number of lines for page up/down command Alt+_period_sl Toggle on/off the status line Alt+_period_slr Toggle status line being shown in reverse video Alt+_period_tab Toggle replace tabs with spaces as you type (defaults to replace) Alt+_period_rts Toggle on/off remove trailing spaces as you type (defaults to don't remove) Alt+p_squote Put string into paste buffer Misc Commands
Alt+_caret_ delete from cursor to start of line Alt+_dollar_ delete from cursor to end of line Alt+_slash_ find forward Alt+_colon_w Save File. Similar to Vi :w Alt+cd Change directory Alt+ed Change to EDIT mode. You almost always want to be in EDIT mode. Alt+he Help. Open lued_bindings.lua Alt+jj Similar to Sublime Ctrl+J. Join lines. Alt+ln show line numbers Alt+ls unix ls command. dos dir command Alt+LU Change to LUA mode. You rarely want to be in lua mode. Alt+wl Wrap line at cursor. Subsequent lines end at previous line. Alt+relued Reload lued script Alt+rl Reload current file Alt+sa Similar to Sublime Ctrl+Shift+S. File Save as. Alt+Seti Set Scope Indent SI2 SI3 SI4