Nano: Difference between revisions
m (Add built-in extra nanorc highlighting files too) |
(Undo revision 804707 by Treyarch (talk) - Issue is still happening on my side, nothing has been changed about "brightnormal" in either nano-syntax-highlighting or nano itself) Tag: Undo |
||
(15 intermediate revisions by 9 users not shown) | |||
Line 7: | Line 7: | ||
[[fr:Nano]] | [[fr:Nano]] | ||
[[ja:Nano]] | [[ja:Nano]] | ||
[[pt:Nano]] | |||
[[ru:Nano]] | [[ru:Nano]] | ||
[[tr:Nano]] | |||
[[zh-hans:Nano]] | [[zh-hans:Nano]] | ||
[https://www.nano-editor.org/ GNU nano] (or nano) is a text editor which aims to introduce a simple interface and intuitive command options to console based text editing. ''nano'' supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and [[Wikipedia:UTF-8|UTF-8]] encoding. ''nano'' opened with an empty buffer typically occupies under 4 MB of resident memory. | [https://www.nano-editor.org/ GNU nano] (or nano) is a text editor which aims to introduce a simple interface and intuitive command options to console based text editing. ''nano'' supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and [[Wikipedia:UTF-8|UTF-8]] encoding. ''nano'' opened with an empty buffer typically occupies under 4 MB of resident memory. | ||
Line 25: | Line 27: | ||
Proceed to establish the nano console environment by setting and/or unsetting commands within {{ic|~/.config/nano/nanorc}} file. | Proceed to establish the nano console environment by setting and/or unsetting commands within {{ic|~/.config/nano/nanorc}} file. | ||
{{Tip|{{man|5|nanorc}} details the complete list configuration commands available for nano. | {{Tip|{{man|5|nanorc}} details the complete list configuration commands available for nano.}} | ||
=== Syntax highlighting === | === Syntax highlighting === | ||
Line 39: | Line 39: | ||
include "/usr/share/nano-syntax-highlighting/*.nanorc" | include "/usr/share/nano-syntax-highlighting/*.nanorc" | ||
{{Note|As of version 2020.10.10-1 of {{Pkg|nano-syntax-highlighting}}, there is a syntax error in {{ic|/usr/share/nano-syntax-highlighting/nanorc.nanorc}}.[https://github.com/scopatz/nanorc/issues/410] To temporarily solve the issue, You can run: | |||
# sed -i 's/icolor brightnormal/icolor normal/g' /usr/share/nano-syntax-highlighting/nanorc.nanorc | |||
}} | |||
==== Forth ==== | ==== Forth ==== | ||
Line 54: | Line 60: | ||
=== Suspension === | === Suspension === | ||
Suspending (i.e. sending nano to the background) is enabled by default, however the default keybind is changed from {{ic|Ctrl+z}} to {{ic|Ctrl+t}} {{ic|Ctrl+z}} and it must be changed if the old behavior is desired. This can be done by checking the {{ic|Key bindings}} section. | |||
== Usage == | == Usage == | ||
Line 79: | Line 83: | ||
=== Replacing vi with nano === | === Replacing vi with nano === | ||
To replace vi with nano as the default text editor for commands such as [[ | To replace vi with nano as the default text editor for commands such as [[visudo]], set the {{ic|VISUAL}} and {{ic|EDITOR}} [[Environment variable#Defining variables|environment variables]], for example: | ||
export VISUAL=nano | export VISUAL=nano |
Latest revision as of 08:12, 27 March 2024
GNU nano (or nano) is a text editor which aims to introduce a simple interface and intuitive command options to console based text editing. nano supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and UTF-8 encoding. nano opened with an empty buffer typically occupies under 4 MB of resident memory.
Installation
Configuration
The look, feel, and function of nano is typically controlled by way of either command-line arguments, or configuration commands within the file ~/.config/nano/nanorc
.
A sample configuration file is installed upon program installation and is located at /etc/nanorc
. To customize your nano configuration, first create a local copy at ~/.config/nano/nanorc
:
$ cp /etc/nanorc ~/.config/nano/nanorc
Proceed to establish the nano console environment by setting and/or unsetting commands within ~/.config/nano/nanorc
file.
Syntax highlighting
Nano ships with predefined syntax highlighting rules, defined in /usr/share/nano/*.nanorc
and /usr/share/nano/extra/*.nanorc
. To enable them, add the following line to your ~/.config/nano/nanorc
or to /etc/nanorc
:
include "/usr/share/nano/*.nanorc" include "/usr/share/nano/extra/*.nanorc"
For syntax highlighting enhancements which replace and expand the defaults, install nano-syntax-highlighting or nano-syntax-highlighting-gitAUR and, additionally to the above setting, also add:
include "/usr/share/nano-syntax-highlighting/*.nanorc"
/usr/share/nano-syntax-highlighting/nanorc.nanorc
.[1] To temporarily solve the issue, You can run:
# sed -i 's/icolor brightnormal/icolor normal/g' /usr/share/nano-syntax-highlighting/nanorc.nanorc
Forth
See https://paste.xinu.at/wc17YG/ for Forth highlighting.
PKGBUILD
Save https://paste.xinu.at/4ss/ (similar to Arch's old svntogit server) to /etc/nano/pkgbuild.nanorc
and include it:
include "/etc/nano/pkgbuild.nanorc"
Suspension
Suspending (i.e. sending nano to the background) is enabled by default, however the default keybind is changed from Ctrl+z
to Ctrl+t
Ctrl+z
and it must be changed if the old behavior is desired. This can be done by checking the Key bindings
section.
Usage
Shortcuts can be viewed from inside nano. See the nano online help files via Ctrl+g
within nano and the nano Command Manual for complete descriptions and additional support.
See also the cheatsheet for nano.
Special functions
Keyboard shortcuts representing commonly used functions are listed along the bottom two lines of the nano screen.
They can be toggled by:
Ctrl
for^
based shortcutsMeta
(typicallyAlt
) orEsc
forM-
based shortcuts
Tips and tricks
Replacing vi with nano
To replace vi with nano as the default text editor for commands such as visudo, set the VISUAL
and EDITOR
environment variables, for example:
export VISUAL=nano export EDITOR=nano
Troubleshooting
Hijacked keybindings
Some window managers have keybindings that conflict with nano, for example Alt+Enter
. Remove or remap them to e.g Super
(with dconf for mutter, muffin and marco) and restart the window manager.
See also
- nano (text editor) - Wikipedia Entry
- GNU nano Homepage - Official Site
- GNU nano Bugs - Bug Reporting
- Improved Nano Syntax Highlighting Files