hellerve / e
- четверг, 7 сентября 2017 г. в 03:14:00
A dead simple editor
Braindead editor. Feels like Vim, only simpler. Inspired by kilo, of course, and a large swath of the code is similar.
It can be scripted through Lua.
main.c
)git clone https://github.com/hellerve/e
cd e
make install # install_lua for Lua support
There are two major modes, init
and edit
. edit
mode works like a normal
text editor would. init
mode enables the user to navigate and do meta work,
such as saving the file, searching, and replacing.
Use wasd
or the arrow keys for movement. Editing (backspace, etc.) works normally.
n
: insert a line below the cursor and start editing (next)p
: insert a line above the cursor and start editing (previous)b
: jump to the beginning of the line and start editingt
: jump to the end of the line and start editing (terminus)h
: hide a line (delete it) and add it to the system clipboard (clipboard only on Windows and OS X)c
: copy a line to the system clipboard (only on Windows and OS X)v
: view (i.e. paste) the contents of the system clipboard (only on Windows and OS X)/
: incremental highlighted searchr
: search and replace first occurrenceR
: search and replace all occurrencesIn meta mode (reachable by pressing the colon character :
), there are
the following commands:
s
: save and quit (might be prompted for a file name)q
: exit (will abort if the file has unsaved content)!
: force exitn
: jump to line n
By default, e
creates a directory called .estx
in the user's home
directory (the location is overridable by providing STXDIR
to make install
).
There, e
will search for syntax files on startup. Their grammar is very
minimal, see the C file below:
displayname: c
extensions: .*\.cpp$
.*\.hpp$
.*\.c$
.*\.h$
comment|no_sep: //.*$
keyword:(restrict|switch|if|while|for|break|continue|return|else|try|catch|else|struct|union|class|typedef|static|enum|case|asm|default|delete|do|explicit|export|extern|inline|namespace|new|public|private|protected|sizeof|template|this|typedef|typeid|typename|using|virtual|friend|goto)
type: (auto|bool|char|const|double|float|inline|int|mutable|register|short|unsigned|volatile|void|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|size_t|ssize_t|time_t)
comment|no_sep: /\*([^(\*/)]*)?
(.*)?\*/
pragma: #(include|pragma|define|undef) .*$
predefined: (NULL|stdout|stderr)
pragma: #(ifdef|ifndef|if) .*$
#endif\w*$
displayname
is the string displayed at the bottom of e
. extensions
is a list of regexes to match the filenames. Highlighting keys are comment
,
keyword
, type
, pragma
, string
, number
, and predefined
. By appending
|no_sep
, the user signals to e
that no separator is needed, i.e. highlighting
works even if the matched string is part of a longer word. The values are regexes.
If you provide a second regex (must by divided by a newline), e
assumes that everything
between the two matches should be colored (useful for e.g. multiline comments).
The editor has scripting capabilities in Lua. Thus far I've only documented them
in a blog post, but this
post should give you a good overview of how to write Lua scripts for e
. There
is also an example .erc
file in the repository that you can look at for inspiration.
That's it!
Have fun!