config.phundrak.com/nanorc.org

6.5 KiB
Raw Blame History

Phundraks nano config

Presentation

Although it is a very simple piece of software, nano does offer some customization. Here is mine.

Configuration

When soft line wrapping is enabled, make it wrap lines at blank characters (tabs and spaces) instead of always at the edge of the screen.

set atblanks

Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragraph).

  set autoindent

When saving a file, create a backup file by adding a tilde (~) to the file's name. And make and keep not just one backup file, but make and keep a uniquely numbered one every time a file is saved — when backups are enabled with set backup or --backup or -B. The uniquely numbered files are stored in the directory ~/.cache/nano/backups/.

  set backup
  set backupdir /home/phundrak/.cache/nano/backups/

Use bold instead of reverse video for the title bar, status bar, key combos, function tags, line numbers, and selected text. This can be overridden by setting the options titlecolor, statuscolor, keycolor, functioncolor, numbercolor, and selectedcolor.

set boldtext

Do case-unsensitive searches by default.

  unset casesensitive

Constantly display the cursor position in the status bar. This overrides the option quickblank.

set constantshow

Display line numbers to the left of the text area.

set linenumbers

Do regular-expression searches by default. Regular expressions in nano are of the extended type (ERE).

set regexp

Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.

set smarthome

Enable soft line wrapping for easier viewing of very long lines.

set softwrap

Use a tab size of a certain amount of columns. The value of number must be greater than 0. The default value is 8.

set tabsize 2

Convert typed tabs to spaces. Sue me.

  set tabstospaces

Remove trailing whitespace from wrapped lines when automatic hard-wrapping occurs or when text is justified.

set trimblanks

Save a file by default in Unix format. This overrides nano's default behavior of saving a file in the format that it had. (This option has no effect when you also use set noconvert.)

set unix

Included configuration file

Nano gives the opportunity to include some files located elsewhere. This is why I added this repo as a submodule of my dotfiles so I can access a lot of them at the same time. Since the submodule is cloned in ~/.config/nanorc, we can add only one line to include all of the .nanorc files.

  include ~/.config/nanorc/*.nanorc