Skip to content

Instantly share code, notes, and snippets.

@Kripta-Studios
Created December 6, 2022 13:42
Show Gist options
  • Select an option

  • Save Kripta-Studios/47085e5daf7a1d5075293bbc575552a6 to your computer and use it in GitHub Desktop.

Select an option

Save Kripta-Studios/47085e5daf7a1d5075293bbc575552a6 to your computer and use it in GitHub Desktop.

Micro PLugins Installed

To read MarkDown in CLI use glow <file.md>

Installed now

comment detectindent filemanager jump manipulator micro-autofmt micro-run glow misspell quoter

comment

ctrl + e comment set commenttype "/* %s */" settings.json Alt-/ (comments selected lines)

detectindent

set detectindent on

filemanager

  • List of options:

Option Purpose Default
filemanager-showdotfiles Show dotfiles (hidden if false) true
filemanager-showignored Show gitignore'd files (hidden if false) true
filemanager-compressparent Collapse the parent dir when left is pressed on a child file true
filemanager-foldersfirst Sorts folders above any files true
filemanager-openonstart Automatically open the file tree when starting Micro false
  • Commands and Keybindings (Ctrl-e):

    • Ctrl-w keybinding is to switch which buffer your
Command Keybinding(s) What it does API for bindings.json
tree - Open/close the tree filemanager.toggle_tree
- Tab & MouseLeft Open a file, or go into the directory. Goes back a dir if on .. filemanager.try_open_at_cursor
- Expand directory in tree listing filemanager.uncompress_at_cursor
- Collapse directory listing filemanager.compress_at_cursor
- Shift ⬆ Go to the target's parent directory filemanager.goto_parent_dir
- Alt Shift { Jump to the previous directory in the view filemanager.goto_next_dir
- Alt Shift } Jump to the next directory in the view filemanager.goto_prev_dir
rm - Prompt to delete the target file/directory your cursor is on filemanager.prompt_delete_at_cursor
rename - Rename the file/directory your cursor is on, using the passed name filemanager.rename_at_cursor
touch - Make a new file under/into the file/directory your cursor is on, using the passed name filemanager.new_file
mkdir - Make a new directory under/into the file/directory your cursor is on, using the passed name filemanager.new_dir

jump

Use F4 to jump between functions and classes

micro-run

Press F5 to save and run the current file, F12 to make, F9 to make in background F12 compiles your project even if Makefile is in a higher directory. F9 runs 'make' in background, allowing you to keep editing while your project compiles.

manipulator

This is an simple plugin to extend text manipulation in Micro If you have a selection, the plugin will change all of the selection.

The following commands currently exists. Insert them with Ctrl-e:

  • upper: UPPERCASE
  • lower: lowercase
  • reverse: Reverses
  • base64enc: Base64 encodes
  • base64dec: Base64 decodes
  • rot13: ROT-13
  • incNum: Increase number by one
  • decNum: Decrease number by one
  • capital: Capitalize First Letter
  • brace: Adds brackets around selection
    • curly: Curly brackets ({ })
    • square: Square brackets ([ ])
    • angle: Angle brackets (< >)
    • dquote: Double quotes (" ")
    • squote: Single quotes (' ')

micro-autofmt

  • Run fmt to format the current file.
  • Files will be formatted on save, unless fmt-onsave is set to false (with Ctrl-e > set fmt-onsave false).

misspell

No idea

quoter

Press [ or { or ' or " while having text selected

Keybindings

Up CursorUp
Down CursorDown
Right CursorRight
Left CursorLeft
ShiftUp SelectUp
ShiftDown SelectDown
ShiftLeft SelectLeft
ShiftRight SelectRight
AltLeft WordLeft
AltRight WordRight
AltUp MoveLinesUp
AltDown MoveLinesDown
CtrlShiftRight SelectWordRight
CtrlShiftLeft SelectWordLeft
AltLeft StartOfTextToggle
AltRight EndOfLine
AltShiftRight SelectWordRight
AltShiftLeft SelectWordLeft
CtrlLeft StartOfText
CtrlRight EndOfLine
AltShiftLeft SelectToStartOfTextToggle
CtrlShiftLeft SelectToStartOfTextToggle
ShiftHome SelectToStartOfTextToggle
AltShiftRight SelectToEndOfLine
CtrlShiftRight SelectToEndOfLine
ShiftEnd SelectToEndOfLine
CtrlUp CursorStart
CtrlDown CursorEnd
CtrlShiftUp SelectToStart
CtrlShiftDown SelectToEnd
Alt-{ ParagraphPrevious
Alt-} ParagraphNext
Enter InsertNewline
Ctrl-h Backspace
Backspace Backspace
Alt-CtrlH DeleteWordLeft
Alt-Backspace DeleteWordLeft
Tab Autocomplete|IndentSelection|InsertTab
Backtab OutdentSelection|OutdentLine
Ctrl-o OpenFile
Ctrl-s Save
Ctrl-f Find
Alt-F FindLiteral
Ctrl-n FindNext
Ctrl-p FindPrevious
Ctrl-z Undo
Ctrl-y Redo
Ctrl-c CopyLine|Copy
Ctrl-x Cut
Ctrl-k CutLine
Ctrl-d DuplicateLine
Ctrl-v Paste
Ctrl-a SelectAll
Ctrl-t AddTab
Alt-, PreviousTab
Alt-. NextTab
Home StartOfText
End EndOfLine
CtrlHome CursorStart
CtrlEnd CursorEnd
PageUp CursorPageUp
PageDown CursorPageDown
CtrlPageUp PreviousTab
CtrlPageDown NextTab
Ctrl-g ToggleHelp
Alt-g ToggleKeyMenu
Ctrl-r ToggleRuler
Ctrl-l command-edit goto
Delete Delete
Ctrl-b ShellMode
Ctrl-q Quit
Ctrl-e CommandMode
Ctrl-w NextSplit
Ctrl-u ToggleMacro
Ctrl-j PlayMacro
Insert ToggleOverwriteMode
// Emacs-style keybindings
Alt-f WordRight
Alt-b WordLeft
Alt-a StartOfLine
Alt-e EndOfLine
// Integration with file managers
F2 Save
F3 Find
F4 Quit
F7 Find
F10 Quit
Esc Escape
// Mouse bindings
MouseWheelUp ScrollUp
MouseWheelDown ScrollDown
MouseLeft MousePress
MouseMiddle PastePrimary
Ctrl-MouseLeft MouseMultiCursor
Alt-n SpawnMultiCursor
AltShiftUp SpawnMultiCursorUp
AltShiftDown SpawnMultiCursorDown
Alt-m SpawnMultiCursorSelect
Alt-p RemoveMultiCursor
Alt-c RemoveAllMultiCursors
Alt-x SkipMultiCursor

Commands

Micro provides the following commands that can be executed at the command-bar by pressing Ctrl-e and entering the command. Arguments are placed in single quotes here but these are not necessary when entering the command in micro.

  • bind 'key' 'action': creates a keybinding from key to action. See the keybindings documentation for more information about binding keys. This command will modify bindings.json and overwrite any bindings to key that already exist.

  • help 'topic'?: opens the corresponding help topic. If no topic is provided opens the default help screen. Help topics are stored as .md files in the runtime/help directory of the source tree, which is embedded in the final binary.

  • save 'filename'?: saves the current buffer. If the file is provided it will 'save as' the filename.

  • quit: quits micro.

  • goto 'line': jumps to the given line number. A negative number can be passed to jump inward from the end of the file; for example, -5 jumps to the 5th-last line in the file.

  • replace 'search' 'value' 'flags'?: This will replace search with value. The flags are optional. Possible flags are:

    • -a: Replace all occurrences at once
    • -l: Do a literal search instead of a regex search

    Note that search must be a valid regex (unless -l is passed). If one of the arguments does not have any spaces in it, you may omit the quotes.

  • replaceall 'search' 'value': this will replace all occurrences of search with value without user confirmation.

    See replace command for more information.

  • set 'option' 'value': sets the option to value. See the options help topic for a list of options you can set. This will modify your settings.json with the new value.

  • setlocal 'option' 'value': sets the option to value locally (only in the current buffer). This will not modify settings.json.

  • show 'option': shows the current value of the given option.

  • run 'sh-command': runs the given shell command in the background. The command's output will be displayed in one line when it finishes running.

  • vsplit 'filename': opens a vertical split with filename. If no filename is provided, a vertical split is opened with an empty buffer.

  • hsplit 'filename': same as vsplit but opens a horizontal split instead of a vertical split.

  • tab 'filename': opens the given file in a new tab.

  • tabmove '[-+]?n': Moves the active tab to another slot. n is an integer. If n is prefixed with - or +, then it represents a relative position (e.g. tabmove +2 moves the tab to the right by 2). If n has no prefix, it represents an absolute position (e.g. tabmove 2 moves the tab to slot 2).

  • tabswitch 'tab': This command will switch to the specified tab. The tab can either be a tab number, or a name of a tab.

  • textfilter 'sh-command': filters the current selection through a shell command as standard input and replaces the selection with the stdout of the shell command. For example, to sort a list of numbers, first select them, and then execute > textfilter sort -n.

  • log: opens a log of all messages and debug statements.

  • plugin list: lists all installed plugins.

  • plugin install 'pl': install a plugin.

  • plugin remove 'pl': remove a plugin.

  • plugin update 'pl': update a plugin (if no arguments are provided updates all plugins).

  • plugin search 'pl': search available plugins for a keyword.

  • plugin available: show available plugins that can be installed.

  • reload: reloads all runtime files.

  • cd 'path': Change the working directory to the given path.

  • pwd: Print the current working directory.

  • open 'filename': Open a file in the current buffer.

  • reset 'option': resets the given option to its default value

  • retab: Replaces all leading tabs with spaces or leading spaces with tabs depending on the value of tabstospaces.

  • raw: micro will open a new tab and show the escape sequence for every event it receives from the terminal. This shows you what micro actually sees from the terminal and helps you see which bindings aren't possible and why. This is most useful for debugging keybindings.

  • showkey: Show the action(s) bound to a given key. For example running > showkey Ctrl-c will display Copy.

  • term exec?: Open a terminal emulator running the given executable. If no executable is given, this will open the default shell in the terminal emulator.

Created by Jinsku Kripta from Kripta-Studios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment