nano: Rebinding Keys

1 
1 7.3 Rebinding Keys
1 ==================
1 
1 Key bindings can be changed via the following three commands in a nanorc
1 file:
1 
1 ‘bind key function menu’
1      Rebinds ‘key’ to ‘function’ in the context of ‘menu’ (or in all
1      menus where the function exists by using ‘all’).
1 
1 ‘bind key "string" menu’
1      Makes ‘key’ produce ‘string’ in the context of ‘menu’ (or in all
1      menus where the key exists when ‘all’ is used).  The ‘string’ can
1      consist of text or commands or a mix of them.  (To enter a command
1      into the ‘string’, precede its keystroke with ‘M-V’.)
1 
1 ‘unbind key menu’
1      Unbinds ‘key’ from ‘menu’ (or from all menus where it exists by
1      using ‘all’).
1 
1 
1    The format of ‘key’ should be one of:
1 
1      ‘^’  followed by an ASCII character or the word "Space".  Example:
1      ‘^C’.
1 
1      ‘M-’  followed by a ASCII character or the word "Space".  Example:
1      ‘M-C’.
1 
1      ‘F’  followed by a numeric value from 1 to 16.  Example: ‘F10’.
1 
1 
1    Valid names for the ‘function’ to be bound are:
1 
1 ‘help’
1      Invokes the help viewer.
1 
1 ‘cancel’
1      Cancels the current command.
1 
1 ‘exit’
1      Exits from the program (or from the help viewer or the file
1      browser).
1 
1 ‘writeout’
1      Writes the current buffer to disk, asking for a name.
1 
1 ‘savefile’
1      Writes the current file to disk without prompting.
1 
1 ‘insert’
1      Inserts a file into the current buffer (at the current cursor
1      position), or into a new buffer when option ‘multibuffer’ is set.
1 
1 ‘whereis’
1      Starts a forward search for text in the current buffer — or for
1      filenames matching a string in the current list in the file
1      browser.
1 
1 ‘wherewas’
1      Starts a backward search for text in the current buffer.
1 
1 ‘searchagain’
1      Repeats the last search command without prompting.
1 
1 ‘findprevious’
1      As ‘searchagain’, but always in the backward direction.
1 
1 ‘findnext’
1      As ‘searchagain’, but always in the forward direction.
1 
1 ‘replace’
1      Interactively replaces text within the current buffer.
1 
1 ‘cut’
1      Cuts and stores the current line (or the marked region).
1 
1 ‘copytext’
1      Copies the current line (or the marked region) without deleting it.
1 
1 ‘uncut’
1      Copies the currently stored text into the current buffer at the
1      current cursor position.
1 
1 ‘mark’
1      Sets the mark at the current position, to start selecting text.
1 
1 ‘cutwordleft’
1      Cuts from the cursor position to the beginning of the preceding
1      word.
1 
1 ‘cutwordright’
1      Cuts from the cursor position to the beginning of the next word.
1 
1 ‘cutrestoffile’
1      Cuts all text from the cursor position till the end of the buffer.
1 
1 ‘curpos’
1      Shows the current cursor position: the line, column, and character
1      positions.
1 
1 ‘wordcount’
1      Counts the number of words, lines and characters in the current
1      buffer.
1 
1 ‘speller’
1      Invokes a spell-checking program (or linting program, or formatter
1      program, if the active syntax defines such a thing).
1 
1 ‘justify’
1      Justifies the current paragraph.  A paragraph is a group of
1      contiguous lines that, apart from possibly the first line, all have
1      the same indentation.  The beginning of a paragraph is detected by
1      either this lone line with a differing indentation or by a
1      preceding blank line.
1 
1 ‘fulljustify’
1      Justifies the entire current buffer.
1 
1 ‘indent’
1      Indents (shifts to the right) the currently marked text.
1 
1 ‘unindent’
1      Unindents (shifts to the left) the currently marked text.
1 
1 ‘comment’
1      Comments or uncomments the current line or marked lines, using the
1      comment style specified in the active syntax.
1 
1 ‘complete’
1      Completes the fragment before the cursor to a full word found
1      elsewhere in the current buffer.
1 
1 ‘left’
1      Goes left one position (in the editor or browser).
1 
1 ‘right’
1      Goes right one position (in the editor or browser).
1 
1 ‘up’
1      Goes one line up (in the editor or browser).
1 
1 ‘down’
1      Goes one line down (in the editor or browser).
1 
1 ‘scrollup’
1      Scrolls the viewport up one row (meaning that the text slides down)
1      while keeping the cursor in the same text position, if possible.
1 
1 ‘scrolldown’
1      Scrolls the viewport down one row (meaning that the text slides up)
1      while keeping the cursor in the same text position, if possible.
1 
1 ‘prevword’
1      Moves the cursor to the beginning of the previous word.
1 
1 ‘nextword’
1      Moves the cursor to the beginning of the next word.
1 
1 ‘home’
1      Moves the cursor to the beginning of the current line.
1 
1 ‘end’
1      Moves the cursor to the end of the current line.
1 
1 ‘beginpara’
1      Moves the cursor to the beginning of the current paragraph.
1 
1 ‘endpara’
1      Moves the cursor to the end of the current paragraph.
1 
1 ‘prevblock’
1      Moves the cursor to the beginning of the current or preceding block
1      of text.  (Blocks are separated by one or more blank lines.)
1 
1 ‘nextblock’
1      Moves the cursor to the beginning of the next block of text.
1 
1 ‘pageup’
1      Goes up one screenful.
1 
1 ‘pagedown’
1      Goes down one screenful.
1 
1 ‘firstline’
1      Goes to the first line of the file.
1 
1 ‘lastline’
1      Goes to the last line of the file.
1 
1 ‘gotoline’
1      Goes to a specific line (and column if specified).  Negative
1      numbers count from the end of the file (and end of the line).
1 
1 ‘findbracket’
1      Moves the cursor to the bracket (brace, parenthesis, etc.)  that
1      matches (pairs) with the one under the cursor.
1 
1 ‘prevbuf’
1      Switches to editing/viewing the previous buffer when multiple
1      buffers are open.
1 
1 ‘nextbuf’
1      Switches to editing/viewing the next buffer when multiple buffers
1      are open.
1 
1 ‘verbatim’
1      Inserts the next keystroke verbatim into the file.
1 
1 ‘tab’
1      Inserts a tab at the current cursor location.
1 
1 ‘enter’
1      Inserts a new line below the current one.
1 
1 ‘delete’
1      Deletes the character under the cursor.
1 
1 ‘backspace’
1      Deletes the character before the cursor.
1 
1 ‘recordmacro’
1      Starts the recording of keystrokes — the keystrokes are stored as a
1      macro.  When already recording, the recording is stopped.
1 
1 ‘runmacro’
1      Replays the keystrokes of the last recorded macro.
1 
1 ‘undo’
1      Undoes the last performed text action (add text, delete text, etc).
1 
1 ‘redo’
1      Redoes the last undone action (i.e., it undoes an undo).
1 
1 ‘refresh’
1      Refreshes the screen.
1 
1 ‘suspend’
1      Suspends the editor (if the suspending function is enabled, see the
1      "suspendenable" entry below).
1 
1 ‘casesens’
1      Toggles case sensitivity in searching (search/replace menus only).
1 
1 ‘regexp’
1      Toggles whether searching/replacing is based on literal strings or
1      regular expressions.
1 
1 ‘backwards’
1      Toggles whether searching/replacing goes forward or backward.
1 
1 ‘prevhistory’
1      Shows the previous history entry in the prompt menus (e.g. search).
1 
1 ‘nexthistory’
1      Shows the next history entry in the prompt menus (e.g. search).
1 
1 ‘flipreplace’
1      Toggles between searching for something and replacing something.
1 
1 ‘flipgoto’
1      Toggles between searching for text and targeting a line number.
1      (The form ‘gototext’ is deprecated.)
1 
1 ‘flipexecute’
1      Toggles between inserting a file and executing a command.
1 
1 ‘flippipe’
1      When executing a command, toggles whether the current buffer (or
1      marked region) is piped to the command.
1 
1 ‘flipnewbuffer’
1      Toggles between inserting into the current buffer and into a new
1      empty buffer.
1 
1 ‘dosformat’
1      When writing a file, switches to writing a DOS format (CR/LF).
1 
1 ‘macformat’
1      When writing a file, switches to writing a Mac format.
1 
1 ‘append’
1      When writing a file, appends to the end instead of overwriting.
1 
1 ‘prepend’
1      When writing a file, ’prepends’ (writes at the beginning) instead
1      of overwriting.
1 
1 ‘backup’
1      When writing a file, creates a backup of the current file.
1 
1 ‘discardbuffer’
1      When about to write a file, discard the current buffer without
1      saving.  (This function is bound by default only when option
1      ‘--tempfile’ is in effect.)
1 
1 ‘browser’
1      Starts the file browser, allowing to select a file from a list.
1 
1 ‘gotodir’
1      Goes to a directory to be specified, allowing to browse anywhere in
1      the filesystem.
1 
1 ‘firstfile’
1      Goes to the first file when using the file browser (reading or
1      writing files).
1 
1 ‘lastfile’
1      Goes to the last file when using the file browser (reading or
1      writing files).
1 
1 ‘nohelp’
1      Toggles the presence of the two-line list of key bindings at the
1      bottom of the screen.
1 
1 ‘constantshow’
1      Toggles the constant display of the current line, column, and
1      character positions.  (The form ‘constupdate’ is deprecated.)
1 
1 ‘morespace’
1      Toggles the presence of the blank line that ’separates’ the title
1      bar from the file text.
1 
1 ‘smoothscroll’
1      Toggles smooth scrolling (when moving around with the arrow keys).
1 
1 ‘softwrap’
1      Toggles the displaying of overlong lines on multiple screen lines.
1 
1 ‘linenumbers’
1      Toggles the display of line numbers in front of the text.
1 
1 ‘whitespacedisplay’
1      Toggles the showing of whitespace.
1 
1 ‘nosyntax’
1      Toggles syntax highlighting.
1 
1 ‘smarthome’
1      Toggles the smartness of the Home key.
1 
1 ‘autoindent’
1      Toggles whether a newly created line will contain the same amount
1      of leading whitespace as the preceding line — or as the next line
1      if the preceding line is the beginning of a paragraph.
1 
1 ‘cutfromcursor’
1      Toggles whether cutting text will cut the whole line or just from
1      the current cursor position to the end of the line.  (The form
1      ‘cuttoend’ is deprecated.)
1 
1 ‘nowrap’
1      Toggles whether long lines will be hard-wrapped to the next line.
1 
1 ‘tabstospaces’
1      Toggles whether typed tabs will be converted to spaces.
1 
1 ‘backupfile’
1      Toggles whether a backup will be made of the file to be edited.
1 
1 ‘multibuffer’
1      Toggles whether a file is inserted into the current buffer or read
1      into a new buffer.
1 
1 ‘mouse’
1      Toggles mouse support.
1 
1 ‘noconvert’
1      Toggles automatic conversion of files from DOS/Mac format.
1 
1 ‘suspendenable’
1      Toggles whether the suspend shortcut (normally ‘^Z’) will suspend
1      the editor.
1 
1 
1    Valid names for ‘menu’ are:
1 
1 ‘main’
1      The main editor window where text is entered and edited.
1 
1 ‘search’
1      The search menu (AKA whereis).
1 
1 ‘replace’
1      The ’search to replace’ menu.
1 
1 ‘replacewith’
1      The ’replace with’ menu, which comes up after ’search to replace’.
1 
1 ‘gotoline’
1      The ’goto line (and column)’ menu.
1 
1 ‘writeout’
1      The ’write file’ menu.
1 
1 ‘insert’
1      The ’insert file’ menu.
1 
1 ‘extcmd’
1      The menu for inserting output from an external command, reached
1      from the insert menu.
1 
1 ‘help’
1      The help-viewer menu.
1 
1 ‘spell’
1      The interactive spell checker Yes/no menu.
1 
1 ‘linter’
1      The linter menu.
1 
1 ‘browser’
1      The file browser, for choosing a file to read from or write to.
1 
1 ‘whereisfile’
1      The ’search for a file’ menu in the file browser.
1 
1 ‘gotodir’
1      The ’go to directory’ menu in the file browser.
1 
1 ‘all’
1      A special name that encompasses all menus.  For ‘bind’ it means all
1      menus where the specified ‘function’ exists; for ‘unbind’ it means
1      all menus where the specified ‘key’ exists.
1