Giter Site home page Giter Site logo

neatvi's Introduction

NEATVI
======

Neatvi is a vi/ex editor.  It can edit bidirectional UTF-8 text.
Original software by Ali Gholami Rudi:
https://github.com/aligrudi/neatvi

NOTICE
======
As of 2021-03-21 neatvi is feature complete & solid stable.
No major updates to be expected.
Only small fixes & optimizations.
Code is|(will|must be) perfect.

FORK CHANGES
------------
1. Added unindent keybind: ^w 
2. Added quickexit to insert mode keybind: kj   
It's important to understand that this has a caveat, if
input comes too fast, for example a paste from terminal and
the sequence has "kj" in it, insert mode will be cancelled mid way
and paste will be wrong. Luckly this almost never happens because
such letter combination is extremely rare.
Can be disabled via :se noqe
3. Added linenumbers, keybind: # (relative numbers are placed after indent)
keybind: v# enables permanent line numbers
4. Added invisible character view, keybind: V   
5. Added regex for changing spaces to tabs, keybind: vi
6. Added regex for removing /r in dos files and trail space/tab, keybind: vo
7. Changed behavior of ^a to change search direction when no more match 
8. Added fssearch, searches what is under the cursor 
in every file in the opened directory keybind: ^] or ^5
Beware that it will brute force open files into buffers and
perform the search. I usually save really often so this isn't 
a problem, but being careless might reload file with unsaved changes.
By default it only checks for .c and .h files. 
for code navigation between files, jump to definitions / etc.
9. fssearch but going in reverse keybind: ^p
10. Added key to change the mark origin which ^p will return to keybind: ^t
11. Added ex command "ea" which opens file case insensitive and ignores the path,
setting an extra number parameter after filename will skip that many matches with
similar path. So for example file might be named "file123.c" but you can open it
just by "ea fi" if this is a uniquely matched filename
12. Added ex command "fd" to set the directory for fssearch or "ea" ex command
13. Added numbered buffers to vi, max 10 and ex "b" command to show buffers
and "b%d" to switch (where %d is the buffer number).
14. Added key to show buffers and switch buffer 
(to switch press corresponding 0-9 number) keybind: ^7
15. Added key to exit vi keybind: qq 
16. Added key to goto line 0 keybind: gg 
17. Added key to delete everything inside (cursor outside) "" keybind: di" or dc"
18. Added key to delete everything inside () keybind: di) or dc)
19. Added key to delete everything inside (cursor outside) () keybind: di( or dc(
20. Added key to change . to -> on cursor line keybind: vh
21. Added key to change -> to . on cursor line keybind: vg
22. Added ex command "z" it does the same thing "!" does but the shell is
launched in interactive mode, so stuff like aliases work. But it will cause
vi to suspend.
23. Changed the colors for C language in conf.c to be sane
24. Added extra highlight keywords for C
25. Added key that splits the line (opposite of J) keybind: K
26. Added key that line wraps text to 80 line limit keybind: gq 
keybind: gw does the same but floors to the last word and is also
much slower.
27. Added key that does multiline repeated edits keybind: v.
This is based on your last commands and insertions and reqires and
argument for how many lines to repeat said operation. When last
operation was 'i' or other commands that enter insert mode
and some text, that text will be placed at the same offset on 
N number of lines specified by the vi_arg1. Direction: top to bottom
28. Added ability to view the numbers for arguments that keys e,w,E,W,b,B
may take. keybind: ^v Pressing again will change the key mode, specifying
any arguments will exit the mode. This is a major step up to how navigation
works in vi, it makes it so much easier to use because now you can see where 
you are going. If not anything else I suggest you to try out this distro
just to see it in action.
29. Added ability to change highlight dynamically. (via syn_reloadft();)
30. New ex option "hww" which highlights every instance of word under the
cursor when enabled. Useful for when studying source code.
31. Added autocomplete in insert mode. Press ^g to index the current opened
file. Then you can press ^n to cycle though the options, results are based on
the contents of the file and the closest match to what you typed. Use ^r to
cycle in reverse.
32. Added ex command "inc" which sets the filename filter for the feature
mentioned in (8.) This is not limited to one argument, 
separate entries by space.
33. Added hund keybind: \
Can also be used from if directories provided in command line args, max 2
A minimalistic terminal file manager.
#### Features
- Vim-inspired hotkeys
- Dual-panel, Vim-like, minimalistic UI
- UTF-8 + wide character support
- Move/remove/copy/rename/chmod/chown selected files
- Recursive chmod with set/unset masks
- Find file in current directory (find as you type)
- Multiple key sorting
- One column at a time (none, size, perm, user, group, atime, ctime, mtime...)
- Marks
- Quick access to shell via `:sh`
- Can be statically linked
#### Environment Variables (which Hund uses)
| Variable | Usage | Default/Fallback |
|-|-|-|
| $VISUAL | $EDITOR | text editor | vi |
| $HOME | user's home directory | /etc/passwd |
| $SHELL | shell used by `:sh` | sh |
#### Commands
Type `?` while in hund for help.
Original software by Michał Czarnecki <[email protected]>
https://github.com/miahuoe/hund.git
34. Added key to save current file keybind: ^k
35. The new special character "/" for ft in conf.c now signifies that 
the regex will be applied on any file. The reason "/" was 
chosen because it's forbidden filename character on unix. It used 
to be "" but in C will make a ptr value of 0, which breaks strcmp
which is used to match highlights.
36. Added a window size signal handler for vi to
redraw the screen automatically.
37. Added history buffer for ex commands when in vi prompt.
keybind: ^b or vb (from normal) will open the buffer with all previous 
commands move the cursor to wanted command and exit buffer with qq  
will copy the command into prompt. You can also use this
when half way through some command and need to access normal
mode to edit the command more efficiently.
38. Added key to grab the current word(s) under the cursor into 
prompt like so :%s/.../ keybind: vr
39. Added ex option to change number of spaces in a tab (\t)
default is set to 8. use :se tbs=N  (N is number of spaces)
40. Added partial support for multiline block regex, for
example C multiline comments syntax highlight.
41. Made lowest row to not waste any space when there
are no messages and actually display the row.
42. Search via '/' or '?' automatically centers and redraws
screen. This partly because change in 41 makes the bottom row
behave dynamically and you might get search result on displayed
on that row, which will be covered by search message instead. 
Also, centering is nice because you always know where to expect
the result to be with your eyes.
43. Added terminal clean up on exit
44. Added a key to perform relative word replacements keybind: vt
Specify arg and the word(s) under the cursor will be placed into prompt,
for example :.,.+5s/\<word\>/ where 5 is the arg.
45. Improved single line performance by roughly 3x
46. Added key to abandon insert discarding any changes keybind: ^x
That means there are 4 ways to exit insert|prompt now: ^x, ^c, ESC, kj 
47. Added Russian keymap, and changed how xkmap_alt works, now
z + arg in normal mode will switch what keymap ^f key changes,
so for example 1 = fa 2 = ru. If you need some other language
kmap just make one yourself. Look into kmap.h it's really simple.
48. Improvement to change 37. Now when in the prompt ^v will bring
up the latest command from history. Also the history works for
searches via / or ? the same way. keybind vv does the same but from
normal mode, to save time. Pressing ^v again goes to next string.
49. Added ability to get more than 1 word for keybinds ^a ^] ^p vr vt v/
specified by number (vi_arg1). Regex control chars will be escaped.
50. Added ability to edit the line while in insert mode
such that backspace can delete all the characters on the line,
when no more characters left the line will be wrapped onto the next
one. This is behavior you can expect from 95% of editors, now neatvi
is not an exception. The same change was done for ^w keybind. 
51. Added key to show the registers and their contents. keybind: R
52. Added a key to perform relative replacement. keybind: ve
Specify arg and the prompt will be for example :.,+5s/ where 5 is
the argument.
53. Added a key to disable autoindent. keybind: va
This is necessary sometimes if you want to paste from system clipboard.
54. Added minimal syntax highlight for js and html
55. Substitute undo-redo point return to where command was issued initially
if the affected area is greater than terminal rows.
56. Modified regex engine to support more than 1 character in negated
char expressions. For example [^&&abc] where ^&& is the not+and. This will
treat "abc" as !(a && b && c) logically. Everything in brackets preceding
&& will be processed according to standard posix negated char.
57. Added ^l key in insert to clean the terminal and start at line 0, 
remove distrations and focus on typing. Useful when running ex via vi -e
58. Added v/ key in normal, grabs the current word(s) under the cursor into 
prompt. If valid, the input will be used for searches using N and n keys.
59. Added ability to remember scroll amount for ^e and ^y keys (specified by vi_arg1).
I felt like they were underused, and unlike ^u and ^d they keep the same 
xcol position, allowing for different use case when you don't want to 
lose cursor pos.

PIKEVM:
-------
A complete rewrite of neatvi's regex engine for the purposes to get
rid of backtracking and severe performance and memory constrants is 
now complete and ready to use. 
Checkout: https://github.com/kyx0r/neatvi/tree/pikevm
See FAQ below for more info.

FAQ:
----
Q: Why neatvi instead of vim?
A: I prefer customization in source code, Vim is considered harmful.

Q: Why not let user choose filemanager (why is hund builtin?)
A: It's impossible to keep the program state between text editor
and filemanager if they are a separate program.
Hund can easily be removed if desired.

Q: Why not distribute as patches, like on suckless.org?
A: It's hard to maintain. Simply put, there are too many changes
to keep track of.

Q: General philosophy?
A: User is programmer, hacker culture.

Q: Keybind with CTRL does not work?
A: vi is reading ASCII codes sent by the terminal. Depending on the
keyboard, the ASCII code could be another key combination. It was
reported that "^^" (Ctrl + ^) can be achieved on some system with "^6".
If something doesn't work, have a look at the layout of an
american/british keyboard and try to reproduce the keybind as if you
have an american/british keyboard.

Q: Something, something - pikevm
A: Pikevm guarantees that all regular expressions are computed in
constant space and O(n+k) time where n is size of the string and
k is some constant for the complexity of the regex ie. how big it is.
Q: What are the other benefits?
A: For example, now it is possible to compute a C comment /* n */ 
where n can be an infinite number of characters. Of course this
extends to every other valid regular expression.
Q: What's wrong with original implementation?
A: Nothing. The backtracker is as good as pikevm when n is small and
usually n is small. That is why it was feasible in the first place.
Q: NFA vs DFA (identify)
A: pikevm = NFA backtrack = DFA
Q: Performance?
A: Both my NFA and DFA implementations are very well written and
optimized, some may even say overly optimized because they are
just one big C macro. As benchmarked the DFA implementation is 2X 
faster than original Ali's implementation and about 15% faster than 
my pikevm NFA. Partly the reason for NFA to be slightly worse is 
because the algorithm itself is a bit fancier and tests performed 
with low N, 30-60 characters. Still, these are very impressive 
results considering the benefits provided by pikevm.
A: Compatibility?
Q: 100% compatible, with exception of posix macros like [:punct:].
I don't use them so I did not bother. DFA has them, they are easy
to implement in pikevm if needed. Any future commits will be done
on both branches if applicable.
A: Minimalism?
Q: Both implementations (regex.c) are ~700 lines of C code, that
includes both the compilation and execution. 

CONFIGURATION
-------------

Edit conf.c to adjust syntax highlighting rules and text direction
patterns.  To define a new keymap, create a new array in kmap.h, like
kmap_fa, and add it to kmaps array in the same header (the first entry
of the new array specifies its name).  The current keymap may be
changed with :cm ex command.  When in input mode, ^e activates the
English kaymap and ^f switches to the alternate keymap (the last
keymap specified with :cm).

COMMANDS
--------

Commands not available in ex(1):

:cm[ap][!] [kmap]
  Without kmap, prints the current keymap name.
  When kmap is specified, sets the alternate keymap to
  kmap and, unless ! is given, switches to this keymap.
:ft [filetype]
  Without filetype, prints the current file type.
  When filetype is specified, sets the file type of the
  current ex buffer.

New key mappings:
^a in normal mode: searches for the word under the cursor.
^p in insert mode: inserts the contents of the default yank buffer.
zL, zl, zr, and zR in normal mode: change the value of td option.
^e and ^f in insert mode: switch to the English and alternate keymap.
ze and zf in normal mode: switch to the English and alternate keymap.
gu, gU, and g~ in normal mode: switch character case.
^l in normal mode: updates terminal dimensions (after resizing it).

OPTIONS
-------

To improve neatvi's performance, shaping, character reordering, and
syntax highlighting can be disabled by defining the EXINIT environment
variable as "set noshape | set noorder | set nohl | set td=+2".

Options supported in neatvi:

td, textdirection
  Current direction context.  The following values are meaningful:
  * +2: always left-to-right.
  * +1: follow conf.c's dircontexts[]; left-to-right for others.
  * -1: follow conf.c's dircontexts[]; right-to-left for others.
  * -2: always right-to-left.
shape
  If set (default), performs Arabic/Farsi letter shaping.
order
  If set, reorder characters based on the rules defined
  in conf.c.
hl, highlight
  If set (default), text will be highlighted based on syntax
  highlighting rules in conf.c.
hll, highlightline
  If set, highlight current line.
ai, autoindent
  As in vi(1).
aw, autowrite
  As in vi(1).
ic, ignorecase
  As in vi(1).

MARKS AND BUFFERS
-----------------

Special marks:
* the position of the previous change
[ the first line of the previous change
] the last line of the previous change

Special yank buffers:
/ the previous search keyword
: the previous ex command

neatvi's People

Contributors

kyx0r avatar vouivre avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.