Added draft for the completion framework
[iomenu.git] / iocomplete.1
blob009de3411e46b09ff3d662b5e32c92d37606db8d
1 .Dd $Mdocdate: September 28 2016 $
2 .Dt IOCOMPLETE 1
3 .Os
4 .Sh NAME
6 .Nm iocomplete
7 .Nd a command line completion backend for iomenu
9 .Sh SYNOPSIS
11 .Nm
12 .Op
15 .Op Ic +command
16 .Op Ar files Fl
18 .Sh DESCRIPTION
20 .Nm vis
21 is a highly efficient vim like text editor.
22 .Bl -tag
23 .It Fl v
24 Print version information and exit.
26 .It Fl -
27 Denotes  the  end  of the options. Arguments after this will be handled as a
28 file name.
29 .El
31 .Ss Modes
33 Vis implements more or less functional normal, operator-pending, insert,
34 replace and visual (in both line and character wise variants) modes.
35 .Pp
36 Visual block mode is not implemented and there exists no immediate plan
37 to do so. Instead vis has built in support for multiple cursors.
38 .Pp
39 Command mode is implemented as a regular file. Use the full power of
40 the editor to edit your commands / search terms.
41 .Pp
42 Ex mode is deliberately not implemented, instead a variant of the
43 structural regular expression based command language of `sam(1)`
44 is supported.
46 .Ss Undo/Redo and Repeat
48 The text is currently snapshotted whenever an operator is completed as
49 well as when insert or replace mode is left. Additionally a snapshot is
50 also taken if in insert or replace mode a certain idle time elapses.
51 .Pp
52 Another idea is to snapshot based on the distance between two consecutive
53 editing operations (as they are likely unrelated and thus should be
54 individually reversible).
55 .Pp
56 Besides the regular undo functionality, the key bindings 
57 .Ql g+
58 and
59 .Ql g-
60 traverse the history in chronological order. Further more the
61 .Iq :earlier
62 and
63 .Iq :later
64 commands provide means to restore the text to an arbitrary
65 state.
66 .Pp
67 The repeat command
68 .Ql \&.
69 works for all operators and is able to repeat
70 the last insertion or replacement.
72 .Ss Tab <-> Space conversion and Line endings \n vs \r\n
74 Tabs can optionally be expanded to a configurable number of spaces.
75 The first line ending in the file determines what will be inserted upon
76 a line break (defaults to \n).
78 .Ss Jump list and change list
80 A per window, file local jump list (navigate with `CTRL+O` and `CTRL+I`)
81 and change list (navigate with `g;` and `g,`) is supported. The jump
82 list is implemented as a fixed sized ring buffer.
84 .Ss Macros
86 The general purpose registers
87 .Ql [a-z]
88 can be used to record macros. Use
89 one of
90 .Ql [A-Z]
91 to append to an existing macro.
92 .Ql q
93 starts a recording,
94 .Ql @
95 plays it back.
96 .Ql @@
97 refers to the least recently recorded macro.
98 .Ql @:
99 repeats the last :-command.
100 .Ql @/
101 is equivalent to
102 .Ql n
103 in normal mode.
105 .Ss Structural Regular Expression based Command Language
107 .Nm vis
108 supports
109 .Xr sam 1
110 structural regular expression based command language.
112 .Ss Mouse support
115 .Sh KEY BINDINGS
117 .Ss Operators
119 .Bl -tag
120 .It c
121 change
123 .It d
124 delete
126 .It !
127 filter
129 .It =
130 indent, currently an alias for gq
132 .It gq
133 format using fmt(1)
135 .It gu
136 make lowercase
138 .It gU
139 make uppercase
141 .It J
142 join
144 .It p
147 .It <
148 shift-left
150 .It >
151 shift-right
153 .It ~
154 swap case
156 .It y
157 yank
160 .Ss Movements
162 .Bl -tag
163 .It 0
164 start of line
166 .It b
167 previous start of a word
169 .It B
170 previous start of a WORD
172 .It $
173 end of line
175 .It e
176 next end of a word
178 .It E
179 next end of a WORD
181 .It F char
182 to next occurrence of char to the left
184 .It f char
185 to next occurrence of char to the right
187 .It ^
188 first non-blank of line
190 .It g0
191 begin of display line
193 .It g$
194 end of display line
196 .It ge
197 previous end of a word
199 .It gE
200 previous end of a WORD
202 .It gg
203 begin of file
205 .It G
206 goto line or end of file
208 .It gj
209 display line down
211 .It gk
212 display line up
214 .It g_
215 last non-blank of line
217 .It gm
218 middle of display line
220 .It |
221 goto column
223 .It h
224 char left
226 .It H
227 goto top/home line of window
229 .It j
230 line down
232 .It k
233 line up
235 .It l
236 char right
238 .It L
239 goto bottom/last line of window
241 .It ` mark
242 go to mark
244 .It ' mark
245 go to start of line containing mark
247 .It %
248 match bracket
250 .It M
251 goto middle line of window
253 .It ]]
254 next end of C-like function
256 .It }
257 next paragraph
259 .It )
260 next sentence
262 .It ][
263 next start of C-like function
265 .It N
266 repeat last search backwards
268 .It n
269 repeat last search forward
271 .It []
272 previous end of C-like function
274 .It [{
275 previous start of block
277 .It ]}
278 next start of block
280 .It [(
281 previous start of parenthese pair
283 .It ])
284 next start of parenthese pair
286 .It {
287 previous paragraph
289 .It (
290 previous sentence
292 .It [[
293 previous start of C-like function
295 .It ;
296 repeat last to/till movement
298 .It ,
299 repeat last to/till movement but in opposite direction
301 .It #
302 search word under cursor backwards
304 .It *
305 search word under cursor forwards
307 .It T char
308 till before next occurrence of char to the left
310 .It t char
311 till before next occurrence of char to the right
313 .It ? text
314 to next match of text in backward direction
316 .It / text
317 to next match of text in forward direction
319 .It w
320 next start of a word
322 .It W
323 next start of a WORD
326 An empty line is currently neither a word nor a WORD.
328 Some of these commands do not work as in vim when prefixed with a
329 digit i.e. a multiplier. As an example in vim
330 .Ql 3$
331 moves to the end
332 of the 3rd line down. However vis treats it as a move to the end of
333 current line which is repeated 3 times where the last two have no
334 effect.
336 .Ss Text objects
338 All of the following text objects are implemented in an inner variant
339 (prefixed with
340 .Ql i`) and a normal variant (prefixed with
341 .Ql a`):
342 .Bl -tag
344 .It w
345 word
347 .It W
348 WORD
350 .It s
351 sentence
353 .It p
354 paragraph
356 .It [,], (,), {,}, <,>, ", ', `
357 block enclosed by these symbols
360 For sentence and paragraph there is no difference between the inner and
361 normal variants.
362 .Bl -tag
364 .It gn
365 matches the last used search term in forward direction
367 .It gN
368 matches the last used search term in backward direction
371 Additionally the following text objects, which are not part of stock
372 vim are also supported:
373 .Bl -tag
375 .It ae
376 entire file content
378 .It ie
379 entire file content except for leading and trailing empty lines
381 .It af
382 C-like function definition including immediately preceding comments
384 .It if
385 C-like function definition only function body
387 .It al
388 current line
390 .It il
391 current line without leading and trailing white spaces
394 .Ss Multiple Cursors / Selections
396 .Nm vis
397 supports multiple cursors with immediate visual feedback (unlike in the
398 visual block mode of vim where for example inserts only become visible
399 upon exit). There always exists one primary cursor located within the
400 current view port. Additional cursors ones can be created as needed. If
401 more than one cursor exists, the primary one is styled differently
402 (yellow by default).
404 To manipulate multiple cursors use in normal mode:
405 .Bl -tag
407 .It Ctrl-K
408 create count new cursors on the lines above
410 .It Ctrl-Meta-K
411 create count new cursors on the lines above the first cursor
413 .It Ctrl-J
414 create count new cursors on the lines below
416 .It Ctrl-Meta-J
417 create count new cursors on the lines below the last cursor
419 .It Ctrl-P
420 remove primary cursor
422 .It Ctrl-N
423 select word the cursor is currently over, switch to visual mode
425 .It Ctrl-U
426 make the count previous cursor primary
428 .It Ctrl-D
429 make the count next cursor primary
431 .It Ctrl-C
432 remove the count cursor column
434 .It Ctrl-L
435 remove all but the count cursor column
437 .It Tab
438 try to align all cursor on the same column
440 .It Esc
441 dispose all but the primary cursor
444 Visual mode was enhanced to recognize:
445 .Bl -tag
447 .It I
448 create a cursor at the start of every selected line
450 .It A
451 create a cursor at the end of every selected line
453 .It Tab
454 left align selections by inserting spaces
456 .It Shift-Tab
457 right align selections by inserting spaces
459 .It Ctrl-N
460 create new cursor and select next word matching current selection
462 .It Ctrl-X
463 clear (skip) current selection, but select next matching word
465 .It Ctrl-P
466 remove primary cursor
468 .It Ctrl-U/K
469 make the count previous cursor primary
471 .It Ctrl-D/J
472 make the count next cursor primary
474 .It Ctrl-C
475 remove the count cursor column
477 .It Ctrl-L
478 remove all but the count cursor column
480 .It +
481 rotates selections rightwards count times
483 .It -
484 rotates selections leftwards count times
486 .It \e
487 trim selections, remove leading and trailing white space
489 .It Esc
490 clear all selections, switch to normal mode
493 In insert/replace mode:
494 .Bl -tag
496 .It Shift-Tab
497 align all cursors by inserting spaces
500 .Ss Marks
502 .Bl -tag
504 .It [a-z]
505 general purpose marks
507 .It <
508 start of the last selected visual area in current buffer
510 .It >
511 end of the last selected visual area in current buffer
514 .Ss Registers
516 Supported registers include:
517 .Bl -tag
519 .It "a-"z
520 general purpose registers
522 .It "A-"Z
523 append to corresponding general purpose register
525 .It "*,
526 "+  system clipboard integration via shell script vis-clipboard
528 .It "0
529 yank register
531 .It "/
532 search register
534 .It ":
535 command register
537 .It "_
538 black hole (/dev/null) register
541 If no explicit register is specified a default register is used.
543 .Sh COMMANDS
546 Besides the sam command language the following commands are also recognized at
547 the `:`-command prompt. Any unique prefix can be used.
548 .Bl -tag
549 .Iq :bdelete
550 close all windows which display the same file as the current one
551 .Iq :earlier
552 revert to older text state
553 .Iq :e
554 replace current file with a new one or reload it from disk
555 .Iq :langmap
556 set key equivalents for layout specific key mappings
557 .Iq :later
558 revert to newer text state
559 .Iq :!
560 launch external command, redirect keyboard input to it
561 .Iq :map
562 add a global key mapping
563 .Iq :map-window
564 add a window local key mapping
565 .Iq :new
566 open an empty window, arrange horizontally
567 .Iq :open
568 open a new window
569 .Iq :qall
570 close all windows, exit editor
571 .Iq :q
572 close currently focused window
574 .It :r
575 insert content of another file at current cursor position
577 .It :set
578 set the options below
580 .It :split
581 split window horizontally
583 .It :s
584 search and replace currently implemented in terms of `sed(1)`
586 .It :unmap
587 remove a global key mapping
589 .It :unmap-window
590 remove a window local key mapping
592 .It :vnew
593 open an empty window, arrange vertically
595 .It :vsplit
596 split window vertically
598 .It :wq
599 write changes then close window
601 .It :w
602 write current buffer content to file
604 .It  tabwidth  [1-8]           default 8
605 set display width of a tab and number of spaces to use if expandtab is enabled
607 .It  expandtab  (yes|no)        default no
608 whether typed in tabs should be expanded to tabwidth spaces
610 .It  autoindent (yes|no)        default no
611 replicate spaces and tabs at the beginning of the line when
613 .It  number         (yes|no)    default no
615 .It  relativenumber (yes|no)    default no
616 whether absolute or relative line numbers are printed alongside
618 .It  syntax      name           default yes
619 use syntax definition given (e.g. "c") or disable syntax
621 .It  show
622 show/hide special white space replacement symbols
623 .Bl -bullet
626 newlines = [0|1]         default 0
629 tabs     = [0|1]         default 0
632 spaces   = [0|1]         default 0
635 .It  cursorline (yes|no)        default no
636 highlight the line on which the cursor currently resides
638 .It  colorcolumn number         default 0
639 highlight the given column
641 .It  horizon    number          default 32768 (32K)
642 how far back the lexer will look to synchronize parsing
644 .It  theme      name            default dark-16.lua | solarized.lua (16 | 256 color)
645 use the given theme / color scheme for syntax highlighting
648 Commands taking a file name will use a simple file open dialog based on
649 the included `vis-open` shell script and `vis-menu` utility, if given
650 a file pattern or directory.
651 .Ic :e *.c
652 opens a menu with all C files
653 .Ic :e \&.
654 opens a menu with all files of the current directory
656 .Ss Runtime Configurable Key Bindings
658 Vis supports run time key bindings via the
659 .Ic :{un,}map{,-window}
660 set of commands. The basic syntax is
661 .Ic :map <mode> <lhs> <rhs>
662 where mode is one of 
663 .Ql normal
665 .Ql insert
667 .Ql replace
669 .Ql visual
671 .Ql visual-line
673 .Ql operator-pending
675 .Ql lhs
676 refers to the key to map,
677 .Ql rhs
678 is a key action or alias. An existing mapping can be overridden by appending
679 .Ql !
680 to the map command.
682 Key mappings are always recursive, this means doing something like
683 .Ic :map! normal j 2j
684 will not work because it will enter an endless loop. Instead vis uses
685 pseudo keys referred to as key actions which can be used to invoke a set
686 of available (see
687 .Ic :help
689 .Ic F1
690 for a list) editor functions. Hence the correct thing to do would be
691 .Ic :map! normal j 2<cursor-line-down>
693 Unmapping works as follows:
694 .Ic :unmap <mode> <lhs>
696 The commands suffixed with `-window` only affect the currently active window.
698 .Ss Layout Specific Key Bindings
700 Vis allows to set key equivalents for non-latin keyboard layouts. This
701 facilitates editing non-latin texts. The defined mappings take effect
702 in all non-input modes, i.e. everywhere except in insert and replace mode.
704 For example, the following maps the movement keys in Russian layout:
705 .Ic :langmap ролд hjkl
707 More generally the syntax of the `:langmap` command is:
708 .Ic :langmap <keys in your layout> <equivalent keys in latin layout>
710 If the key sequences have not the same length, the rest of the longer
711 sequence will be discarded.
713 .Ss Runtime Configurable Key Bindings
715 Vis supports run time key bindings via the
716 .Ic :{un,}map{,-window}
717 set of commands. The basic syntax is
718 .Ic :map <mode> <lhs> <rhs>
719 where mode is one of 
720 .Ql normal
722 .Ql insert
724 .Ql replace
726 .Ql visual
728 .Ql visual-line
730 .Ql operator-pending
732 .Ql lhs
733 refers to the key to map,
734 .Ql rhs
735 is a key action or alias. An existing mapping can be overridden by appending
736 .Ql !
737 to the map command.
739 Key mappings are always recursive, this means doing something like
740 .Ic :map! normal j 2j
741 will not work because it will enter an endless loop. Instead vis uses
742 pseudo keys referred to as key actions which can be used to invoke a set
743 of available (see
744 .Ic :help
746 .Ic F1
747 for a list) editor functions. Hence the correct thing to do would be
748 .Ic :map! normal j 2<cursor-line-down>
750 Unmapping works as follows:
751 .Ic :unmap <mode> <lhs>
753 The commands suffixed with `-window` only affect the currently active window.
755 .Ss Layout Specific Key Bindings
757 Vis allows to set key equivalents for non-latin keyboard layouts. This
758 facilitates editing non-latin texts. The defined mappings take effect
759 in all non-input modes, i.e. everywhere except in insert and replace mode.
761 For example, the following maps the movement keys in Russian layout:
762 .Ic :langmap ролд hjkl
764 More generally the syntax of the `:langmap` command is:
765 .Ic :langmap <keys in your layout> <equivalent keys in latin layout>
767 If the key sequences have not the same length, the rest of the longer
768 sequence will be discarded.
770 .Sh ENVIRONMENT
772 .Bl -tag
773 .Ev VIS_PATH
774 Override path to look for Lua support files as used for  syntax  highlighting.
775 Defaults (in this order) to:
776 .Bl -bullet
779 The location of the vis binary
782 .Pa $XDG_CONFIG_HOME/vis
783 where
784 .Ev $XDG_CONFIG_HOME
785 refers to
786 .Pa $HOME/.config
787 if unset
790 .Pa /usr/local/share/vis
793 .Pa /usr/share/vis
795 .Ev VIS_THEME
796 Override syntax highlighting theme to use.
799 .Sh FILES
802 Settings and keymaps can be specified in a
803 .Pa visrc.lua
804 file, which will
805 be read by
806 .Pa vis
807 at runtime. An example
808 .Pa visrc.lua
809 file is installed in
810 .Pa /usr/local/share/vis
811 by default. This file can be copied to
812 .Pa $XDG_CONFIG_HOME/vis
813 (which defaults to
814 .Pa $HOME/.config/vis
815 ) for further configuration.
817 The environment variable
818 .Pa VIS_PATH
819 can be set to override the path that
820 .Pa vis
821 will look for Lua support files as used for syntax highlighting.
822 .Pa VIS_PATH
823 defaults (in this order) to:
824 .Bl -bullet
827 The location of the
828 .Nm vis
829 binary
832 .Pa $XDG_CONFIG_HOME/vis
833 where
834 .Pa $XDG_CONFIG_HOME
835 refers to
836 .Pa $HOME/.config
837 if unset.
840 .Pa /usr/local/share/vis
843 .Pa /usr/share/vis
846 The environment variable
847 .Ev VIS_THEME
848 can be set to specify the theme used by
849 .Nm vis
851 .Bd -literal
852 VIS_THEME=/path/to/your/theme.lua
853 export VIS_THEME
856 .Sh SEE ALSO
858 .Xr vis-menu 1
859 .Xr vis-open 1
860 .Xr vis-clipboard 1
861 .Xr vis-complete 1
863 .Sh AUTHORS
865 .Nm vis
866 is written by
867 .An Marc André Tanner Aq mat at brain-dump.org