Add multiple cursor docs + improve docs in general

This commit is contained in:
Zachary Yedidia 2017-06-17 17:36:27 -04:00
parent 681da2e90c
commit 397361f23d
4 changed files with 175 additions and 228 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,224 +1,126 @@
#Default Keys # Default Keys
Below are simple charts of the default hotkeys and their functions. Below are simple charts of the default hotkeys and their functions.
For more information about binding custom hotkeys or changing For more information about binding custom hotkeys or changing
default bindings, please run `>help keybindings` default bindings, please run `> help keybindings`
Please remember that *all* keys here are rebindable! Please remember that *all* keys here are rebindable!
If you don't like it, you can change it! If you don't like it, you can change it!
(We are not responsible for you forgetting what you bind keys to. # Power user
Do not open an issue because you forgot your keybindings.)
#Power user | Key | Description of function |
+--------+---------------------------------------------------------+ |-------- |-------------------------------------------------------------------------------------------------- |
| Key | Description of function | | Ctrl+E | Open a command prompt for running commands (see `> help commands` for a list of valid commands). |
+--------+---------------------------------------------------------+ | Tab | In command prompt, it will autocomplete if possible. |
| Ctrl+E | Switch to the micro command prompt to run a command. | | Ctrl+B | Run a shell command (this will close micro while your command executes). |
| | (See `>help commands` for a list of commands. ) |
+--------+---------------------------------------------------------+
| Tab | In command prompt it will auto complete if possible. |
+--------+---------------------------------------------------------+
| Ctrl+B | Run shell commands in micro's current working directory.|
+--------+---------------------------------------------------------+
#Navigation # Navigation
|--------+---------------------------------------------------------+
| Arrows | Move the cursor around your current document. |
| | (Yes this is rebindable to the vim keys if you want.) |
+--------+---------------------------------------------------------+
| Shift+ | Move and select text. |
| Arrows | |
+--------+---------------------------------------------------------+
| Home | |
| or | |
| Ctrl+ | Move to the beginning of the current line. (Naturally.) |
| Left | |
| Arrow | |
+--------+---------------------------------------------------------+
| End | |
| or | |
| Ctrl+ | Move to the end of the current line. |
| Right | |
| Arrow | |
+--------+---------------------------------------------------------+
| Alt+ | |
| Left | Move cursor one complete word left. |
| Arrow | |
+--------+---------------------------------------------------------+
| Alt+ | |
| Right | Move cursor one complete word right. |
| Arrow | |
+--------+---------------------------------------------------------+
| PageUp | Move cursor up lines quickly. |
+--------+---------------------------------------------------------+
| PageDn | Move cursor down lines quickly. |
+--------+---------------------------------------------------------+
| Ctrl+ | |
| Home | |
| or | Move cursor to start of the document |
| Ctrl+ | |
| Up | |
| Arrow | |
+--------+---------------------------------------------------------+
| Ctrl+ | |
| End | |
| or | Move cursor to end of the document |
| Ctrl+ | |
| Down | |
| Arrow | |
+--------+---------------------------------------------------------+
| Ctrl+L | Jump to line in current file. ( Prompts for line # ) |
+--------+---------------------------------------------------------+
| Ctrl+W | Move between splits open in current tab. |
| | (See vsplit and hsplit in `>help commands`) |
+--------+---------------------------------------------------------+
#Tabs | Key | Description of function |
+--------+---------------------------------------------------------+ |-------------------------- |------------------------------------------------------------------------------------------ |
| Ctrl+T | Open a new tab. | | Arrows | Move the cursor around |
+--------+---------------------------------------------------------+ | Shift+arrows | Move and select text |
| Alt+, | Move to the previous tab in the tablist. | | Home or CtrlLeftArrow | Move to the beginning of the current line |
| | (This works like moving between file buffers in nano) | | End or CtrlRightArrow | Move to the end of the current line |
+--------+---------------------------------------------------------+ | AltLeftArrow | Move cursor one word left |
| Alt+. | Move to the next tab in the tablist. | | AltRightArrow | Move cursor one word right |
+--------+---------------------------------------------------------+ | PageUp | Move cursor up one page |
| PageDown | Move cursor down one page |
| CtrlHome or CtrlUpArrow | Move cursor to start of document |
| CtrlEnd or CtrlDownArrow | Move cursor to end of document |
| Ctrl+L | Jump to a line in the file (prompts with #) |
| Ctrl+W | Cycle between splits in the current tab (use `> vsplit` or `> hsplit` to create a split) |
#Find Operations # Tabs
+--------+---------------------------------------------------------+
| Ctrl+F | Find text in current file. ( Prompts for text to find.) |
+--------+---------------------------------------------------------+
| Ctrl+N | Find next instance of current search in current file. |
+--------+---------------------------------------------------------+
| Ctrl+P | Find prev instance of current search in current file. |
+--------+---------------------------------------------------------+
#File Operations | Key | Description of function |
+--------+---------------------------------------------------------+ |-------- |------------------------- |
| Ctrl+Q | Close current file. ( Quits micro if last file open. ) | | Ctrl+T | Open a new tab |
+--------+---------------------------------------------------------+ | Alt+, | Previous tab |
| Ctrl+O | Open a file. ( Prompts you to input filename. ) | | Alt+. | Next tab |
+--------+---------------------------------------------------------+
| Ctrl+S | Save current file. |
+--------+---------------------------------------------------------+
#Text operations # Find Operations
+--------+---------------------------------------------------------+
| Ctrl+A | Select all text in current file. |
+--------+---------------------------------------------------------+
| Alt+ | |
| Shift+ | Select complete word right. |
| Right | |
| Arrow | |
+--------+---------------------------------------------------------+
| Alt+ | |
| Shift+ | Select complete word left. |
| Left | |
| Arrow | |
+--------+---------------------------------------------------------+
| Shift+ | |
| Home | |
| or | Select from the current cursor position to the |
| Ctrl+ | start of the current line. |
| Shift+ | |
| Left | |
| Arrow | |
+--------+---------------------------------------------------------+
| Shift+ | |
| End | |
| or | Select from the current cursor position to the |
| Ctrl+ | end of the current line. |
| Shift+ | |
| Right | |
| Arrow | |
+--------+---------------------------------------------------------+
| Ctrl+ | |
| Shift+ | Select from the current cursor position to the |
| Up | start of the document. |
| Arrow | |
+--------+---------------------------------------------------------+
| Ctrl+ | |
| Shift+ | Select from the current cursor position to the |
| Down | end of the document. |
| Arrow | |
+--------+---------------------------------------------------------+
| Ctrl+X | Cut selected text. |
+--------+---------------------------------------------------------+
| Ctrl+C | Copy selected text. |
+--------+---------------------------------------------------------+
| Ctrl+V | Paste selected text. |
+--------+---------------------------------------------------------+
| Ctrl+K | Cut current line. ( Can then be pasted with Ctrl+V) |
+--------+---------------------------------------------------------+
| Ctrl+D | Duplicate current line. |
+--------+---------------------------------------------------------+
| Ctrl+Z | Undo actions. |
+--------+---------------------------------------------------------+
| Ctrl+Y | Redo actions. |
+--------+---------------------------------------------------------+
| Alt+ | |
| Up | Move current line or selected lines up. |
| Arrow | |
+--------+---------------------------------------------------------+
| Alt+ | |
| Down | Move current line or selected lines down. |
| Arrow | |
+--------+---------------------------------------------------------+
| Alt+ | |
| Ctrl+H | |
| or | Delete complete word left. |
| Alt+ | |
| Back- | |
| space | |
+--------+---------------------------------------------------------+
#Macros | Key | Description of function |
+--------+---------------------------------------------------------+ |-------- |------------------------------------------ |
| | Toggle ON/OFF macro recording. | | Ctrl+F | Find (opens prompt) |
| Ctrl+U | Simply press Ctrl+U to begin recording a macro and | | Ctrl+N | Find next instance of current search |
| | press Ctrl+U to stop recording macro. | | Ctrl+P | Find previous instance of current search |
+--------+---------------------------------------------------------+
| Ctrl+J | Run your recorded macro. |
+--------+---------------------------------------------------------+
#Other # File Operations
+--------+---------------------------------------------------------+
| Ctrl+G | Open the help file. |
+--------+---------------------------------------------------------+
| Ctrl+H | Alternate backspace. |
| | (Some old terminals don't support the Backspace key .) |
+--------+---------------------------------------------------------+
| Ctrl+R | Toggle the line number ruler. ( On the lefthand side.) |
+--------+---------------------------------------------------------+
#Emacs style actions | Key | Description of function |
+--------+---------------------------------------------------------+ |-------- |---------------------------------------------------------------- |
| Alt+F | Move to the end of the next word. (To the next space.) | | Ctrl+Q | Close current file (quits micro if this is the last file open) |
+--------+---------------------------------------------------------+ | Ctrl+O | Open a file (prompts for filename) |
| Alt+B | Move to the beginning of the previous word. | | Ctrl+S | Save current file |
+--------+---------------------------------------------------------+
| Alt+A | Alternate Home key. ( Move to beginning of line. ) | # Text operations
+--------+---------------------------------------------------------+
| Alt+E | Alternate End key. ( Move to the end of line.) | | Key | Description of function |
+--------+---------------------------------------------------------+ |--------------------------------- |------------------------------------------ |
| Alt+P | Move cursor up. ( Same as up key. ) | | AltShiftRightArrow | Select word right |
+--------+---------------------------------------------------------+ | AltShiftLeftArrow | Select word left |
| Alt+N | Move cursor down. ( Same as down key. ) | | ShiftHome or CtrlShiftLeftArrow | Select to start of current line |
+--------+---------------------------------------------------------+ | ShiftEnd or CtrlShiftRightArrow | Select to end of current line |
| CtrlShiftUpArrow | Select to start of file |
| CtrlShiftDownArrow | Select to end of file |
| Ctrl+X | Cut selected text |
| Ctrl+C | Copy selected text |
| Ctrl+V | Paste |
| Ctrl+K | Cut current line |
| Ctrl+D | Duplicate current line |
| Ctrl+Z | Undo |
| Ctrl+Y | Redo |
| AltUpArrow | Move current line or selected lines up |
| AltDownArrow | Move current line of selected lines down |
| AltBackspace or AltCtrl+H | Delete word left |
| Ctrl+A | Select all |
# Macros
| Key | Description of function |
|-------- |---------------------------------------------------------------------------------- |
| Ctrl+U | Toggle macro recording (press Ctrl+U to start recording and press again to stop) |
| Ctrl+J | Run latest recorded macro |
# Multiple cursors
| Key | Description of function |
|---------------- |---------------------------------------------------------------------------------------------- |
| Alt+N | Create new multiple cursor from selection (will select current word if no current selection) |
| Alt+P | Remove latest multiple cursor |
| Alt+C | Remove all multiple cursors (cancel) |
| Alt+X | Skip multiple cursor selection |
| Ctrl-MouseLeft | Place a multiple cursor at any location |
# Other
| Key | Description of function |
|-------- |----------------------------------------------------------------------------------- |
| Ctrl+G | Open help file |
| Ctrl+H | Backspace (old terminals do not support the backspace key and use Ctrl+H instead) |
| Ctrl+R | Toggle the line number ruler |
# Emacs style actions
| Key | Description of function |
|------- |------------------------- |
| Alt+F | Next word |
| Alt+B | Previous word |
| Alt+A | Move to start of line |
| Alt+E | Move to end of line |
# Function keys.
#Function keys.
Warning! The function keys may not work in all terminals! Warning! The function keys may not work in all terminals!
+--------+---------------------------------------------------------+
| F1 | Open help. |
+--------+---------------------------------------------------------+
| F2 | Save current file. |
+--------+---------------------------------------------------------+
| F3 | Find in current file. ( Same as Ctrl+F ) |
+--------+---------------------------------------------------------+
| F4 | Close current file. (Quit if only file.) |
+--------+---------------------------------------------------------+
| F7 | Find in current file. (Same as Ctrl+F) |
+--------+---------------------------------------------------------+
| F10 | Close current file. |
+--------+---------------------------------------------------------+
| Key | Description of function |
|----- |------------------------- |
| F1 | Open help |
| F2 | Save |
| F3 | Find |
| F4 | Quit |
| F7 | Find |
| F10 | Quit |

View File

@ -131,9 +131,22 @@ HSplit
PreviousSplit PreviousSplit
ToggleMacro ToggleMacro
PlayMacro PlayMacro
Suspend (Linux only)
ScrollUp
ScrollDown
SpawnMultiCursor
RemoveMultiCursor
RemoveAllMultiCursors
SkipMultiCursor
UnbindKey UnbindKey
``` ```
You can also bind some mouse actions (these must be bound to mouse buttons)
```
MousePress
MouseMultiCursor
```
Here is the list of all possible keys you can bind: Here is the list of all possible keys you can bind:
``` ```
@ -262,6 +275,18 @@ Escape
Enter Enter
``` ```
You can also bind some mouse buttons (they may be bound to normal actions or mouse actions)
```
MouseLeft
MouseMiddle
MouseRight
MouseWheelUp
MouseWheelDown
MouseWheelLeft
MouseWheelRight
```
# Default keybinding configuration. # Default keybinding configuration.
```json ```json
@ -276,10 +301,10 @@ Enter
"ShiftRight": "SelectRight", "ShiftRight": "SelectRight",
"AltLeft": "WordLeft", "AltLeft": "WordLeft",
"AltRight": "WordRight", "AltRight": "WordRight",
"AltShiftRight": "SelectWordRight",
"AltShiftLeft": "SelectWordLeft",
"AltUp": "MoveLinesUp", "AltUp": "MoveLinesUp",
"AltDown": "MoveLinesDown", "AltDown": "MoveLinesDown",
"AltShiftRight": "SelectWordRight",
"AltShiftLeft": "SelectWordLeft",
"CtrlLeft": "StartOfLine", "CtrlLeft": "StartOfLine",
"CtrlRight": "EndOfLine", "CtrlRight": "EndOfLine",
"CtrlShiftLeft": "SelectToStartOfLine", "CtrlShiftLeft": "SelectToStartOfLine",
@ -291,13 +316,12 @@ Enter
"CtrlShiftUp": "SelectToStart", "CtrlShiftUp": "SelectToStart",
"CtrlShiftDown": "SelectToEnd", "CtrlShiftDown": "SelectToEnd",
"Enter": "InsertNewline", "Enter": "InsertNewline",
"Space": "InsertSpace",
"CtrlH": "Backspace", "CtrlH": "Backspace",
"Backspace": "Backspace", "Backspace": "Backspace",
"Alt-CtrlH": "DeleteWordLeft", "Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft", "Alt-Backspace": "DeleteWordLeft",
"Tab": "IndentSelection,InsertTab", "Tab": "IndentSelection,InsertTab",
"Backtab": "OutdentSelection", "Backtab": "OutdentSelection,OutdentLine",
"CtrlO": "OpenFile", "CtrlO": "OpenFile",
"CtrlS": "Save", "CtrlS": "Save",
"CtrlF": "Find", "CtrlF": "Find",
@ -336,8 +360,6 @@ Enter
"Alt-b": "WordLeft", "Alt-b": "WordLeft",
"Alt-a": "StartOfLine", "Alt-a": "StartOfLine",
"Alt-e": "EndOfLine", "Alt-e": "EndOfLine",
"Alt-p": "CursorUp",
"Alt-n": "CursorDown",
// Integration with file managers // Integration with file managers
"F1": "ToggleHelp", "F1": "ToggleHelp",
@ -347,10 +369,23 @@ Enter
"F7": "Find", "F7": "Find",
"F10": "Quit", "F10": "Quit",
"Esc": "Escape", "Esc": "Escape",
// Mouse bindings
"MouseWheelUp": "ScrollUp",
"MouseWheelDown": "ScrollDown",
"MouseLeft": "MousePress",
"MouseMiddle": "PastePrimary",
"Ctrl-MouseLeft": "MouseMultiCursor",
// Multiple cursors bindings
"Alt-n": "SpawnMultiCursor",
"Alt-p": "RemoveMultiCursor",
"Alt-c": "RemoveAllMultiCursors",
"Alt-x": "SkipMultiCursor",
} }
``` ```
#Final notes # Final notes
Note: On some old terminal emulators and on Windows machines, `CtrlH` should be used Note: On some old terminal emulators and on Windows machines, `CtrlH` should be used
for backspace. for backspace.

View File

@ -21,6 +21,16 @@ This is almost always the current view, which you can get with `CurView()` as we
All available actions are listed in the keybindings section of the help. All available actions are listed in the keybindings section of the help.
For callbacks to mouse actions, you are also given the event info:
```lua
function onMousePress(view, event)
local x, y = event:Position()
return false
end
```
These functions should also return a boolean specifying whether the view These functions should also return a boolean specifying whether the view
should be relocated to the cursor or not after the action is complete. should be relocated to the cursor or not after the action is complete.
@ -156,25 +166,25 @@ See this example to learn how to use `MakeCompletion` and `MakeCommand`
```lua ```lua
local function StartsWith(String,Start) local function StartsWith(String,Start)
String = String:upper() String = String:upper()
Start = Start:upper() Start = Start:upper()
return string.sub(String,1,string.len(Start))==Start return string.sub(String,1,string.len(Start))==Start
end end
function complete(input) function complete(input)
local allCompletions = {"Hello", "World", "Foo", "Bar"} local allCompletions = {"Hello", "World", "Foo", "Bar"}
local result = {} local result = {}
for i,v in pairs(allCompletions) do for i,v in pairs(allCompletions) do
if StartsWith(v, input) then if StartsWith(v, input) then
table.insert(result, v) table.insert(result, v)
end end
end end
return result return result
end end
function foo(arg) function foo(arg)
messenger:Message(arg) messenger:Message(arg)
end end
MakeCommand("foo", "example.foo", MakeCompletion("example.complete")) MakeCommand("foo", "example.foo", MakeCompletion("example.complete"))