nano: Rebinding Keys

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