`Nano`sphere
Tags: beginners, tutorial, learning, codenewbie
Published: 2024-01-31 16:24:59

## Blastoff 🚀

You know!!! I just wanted to make nano work for me, and I went down this rabbit hole, just a bit 😂🤣

If I want to get line numbers, have mouse functionality, and at least be able to use `CTRL-V`, `CTRL-C`, and `CTRL-F` 🫤 you know🧐 things I'm used to on non-terminal things 😩 then, I thought 🤔 I need to setup a file to customize nano to my taste, right? Sure do!

![Black & White two hands, fist close, with thumbs touching] (https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1nm3aglzfd8nu6bl05p7.jpg)  Photo by srini on [Pexels.com](https://www.pexels.com/photo/close-up-of-hands-of-man-and-woman-touching-thumbs-12798521/)


## The Yellow Brick Road

Welp, I went down the yellow brick road, or should I say fell down the rabbit hole?! 😂 Either way, I created a `~/.config/nano/` directory and placed a `.nanorc` file in there. I also created a `~/.cache/nano/backups/` file to act as another location where data from what I'm working on gets saved too when I hit save on the original. The way I'm seeing it is like a manual versioning 😁.

Now, I said something key here, _hit save_. So, it doesn't save automatically. That's key, backups only occur when original saves 😁 Either way, initial goal ✅


![Screenshot of terminal showing creation of nano and backup folders](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnem5ov89er5y3uw19q6.png)

```
:~$ mkdir -p ~/.config/nano ## contains the nanorc file

:~$ mkdir -p ~/.cache/nano/backups/ ## backup folder
```


![A person holding a tablet and raising her hand Description
automatically generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zeombc7hhw1yle6niy5z.jpg)Photo by Andrea Piacquadio on [Pexels.com](https://www.pexels.com/photo/photo-of-a-woman-holding-an-ipad-761977/)

Nope, not done, wait a minute, didn't stop ⛔ there. I wanted to keep ~~playing~~, oops, I meant experimenting with it... and for sure, yep, my experimenting 🤬 it up 🤣😂 I mean, I had my line numbers, auto indent, and `CTRL-V`, `CTRL-C`, `CTRL-S` and mouse support 🪤, but then I had to go and be like why not add `syntax` support and shit 🤔👀

Me looking at myself 👀🤣 I mean... What could go wrong?!

![A person in a hat Description automatically
generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oq192wmemn1czshqx7el.jpg)Photo by Brett Sayles on [Pexels.com](https://www.pexels.com/photo/man-with-facial-expression-at-picture-taking-2771786/)


Really!!! Why!!!

![A person in a suit with his hands up in front of a computer
Description automatically generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0kn7xpl1i938mzbh6tr.jpg)Photo by Andrea Piacquadio on [Pexels.com](https://www.pexels.com/photo/man-showing-distress-3777572/)



## Shit went wrong! 🙀

I indeed went down that rabbit hole again 🐰 and, too long didn't read (TLDR), I landed on [Scopatz/nanorc Github](https://github.com/scopatz/nanorc), which had a nice magic wand 🪄 in the form of an [install.sh](https://github.com/scopatz/nanorc?tab=readme-ov-file#1-automatic-installer) 🙌 Welp, I would like to say that all went well, but as you can probably tell by the next paragraph, I 🤬 again 🤣 I followed steps and all, the issue though, I wasn't expecting to get assimilated

![A group of men standing in a line, with the words "resistance is futile"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1izdvq9hbs5dtsenzeqs.jpg)Image by <a href="https://pixabay.com/users/diggeo-305964/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=373783">George</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=373783">Pixabay</a>

So, now none of my shit worked! I'm laughing at myself and pulling my hair and laughing again 🤣

![A person holding her hair Description automatically
generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqvckexsygpjhrcgvu09.jpg)Photo by SHVETS production on [Pexels.com](https://www.pexels.com/photo/young-obese-woman-rumpling-hair-with-closed-eyes-in-white-studio-6975383/)

`Nano` wasn't reading the `~/.config/nano` directory anymore. No matter what I tried to do, from `symlink` or renaming the `.nanorc` file in that directory and `re-symlink` or adding the `configs` I had in my `./nano/nanorc` to the `.nanorc` file created at the `~/.nano/nanorc.nanorc`, nothing and I mean nothing worked. Instead, the `errors` came to work though 😁

```
Error in ~/.nano/nanorc.nanorc on line 52: Command "set" not allowed in included file

Error in ~/.nano/nanorc.nanorc on line 59: Command "include" not allowed in included file

Error in ~/.nano/nanorc.nanorc on line 76: Command "bind" not allowed in included file
```

So, after a bit of looking around trying to find how to get things working together and even trying things out myself, of course I find that nano has some minimal syntax enabled by default, to my understanding, of the [nano wiki](https://wiki.gentoo.org/wiki/Nano) on [Gentoo](https://wiki.gentoo.org/).

I got two other things out of that too 😁 One, if I want to get real use out of [syntax support](https://wiki.gentoo.org/wiki/Nano#Syntax_highlighting) in `nano`, I will have to enable `plugins` and things, which I thought I was doing 😁 Two, something from the [Gentoo Configuration](https://wiki.gentoo.org/wiki/Nano#Configuration) section caught my eyes. Guilty, ✋, I was skimming through the text, catching what I think was important, to me, and caught this: "to change options only for one user, set the option in the user's `~/.nanorc` file. As a general rule, files present in a user's `$HOME` directory override system wide settings". So now I know why I got "Borged", or assimilated, for those who don't know Star Trek parlor 😁

Anyways, what I decided to do was remove the created directories, which were done by the [automated installer](https://github.com/scopatz/nanorc?tab=readme-ov-file#1-automatic-installer) from [scopatz's](https://github.com/scopatz) [githut](https://github.com/scopatz/nanorc). I copied his configurations, to a custom `.nanorc` file 🧐 I called `syntax_config.nanorc` and then I link it to our my main `~/.config/nano/nanorc.nanorc`, in same directory, through an `include` tag and boom we got `nano` back baby 😎🙌

![A group of people in a cloud of colored powder Description
automatically generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ctkzizfgav24x1cx5og.jpg)Photo by Marcin Dampc on [Pexels.com](https://www.pexels.com/photo/group-of-people-having-neon-party-1684187/)


## Side trick 😉

Side note, when I ran the [auto installer](https://github.com/scopatz/nanorc?tab=readme-ov-file#1-automatic-installer), provided by [scopatz](https://github.com/scopatz), there was an error message that kept popping up when accessing `nano`:

![A screenshot of a computer terminal, linux, showing nano editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvgwpy8zirpgicghpu7b.png)

`Error in ~/.nano/nanorc.nanorc on line 26: Color 'normal' takes     no prefix`

To fix this problem, I opened the `./nanorc.nanorc` file and edited the line that said `icolor brightnormal " brightnormal"` by removing prefix word `bright` from both `normal` tags, then saved and exited.


![A screenshot of computer screen with text and a red box pointing to changed section of config file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vtzxio3jchju7mfvxwcl.png)

Now, if something similar ends happening somewhere 😭, then what I would do is go into the file and copy everything and save them into a text document and back it up somewhere so that I can create that file I spoke of earlier, above ⬆️

Now, I don't know about you, but I am good today with being a glutton for punishment, so I went ahead and pasted the [install.sh](https://github.com/scopatz/nanorc?tab=readme-ov-file#1-automatic-installer), with the corrected section, from [scopatz](https://github.com/scopatz)'s [auto installer](https://github.com/scopatz/nanorc?tab=readme-ov-file#1-automatic-installer) so that if I somehow misplaced it, hey, 🤷, I got it here too 😁

`curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | sh`
from his [Github](https://github.com/scopatz/nanorc)


![Illustration of Man shrugging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh2wgie42ucewxeodhja.png) illustration by [Firkin](https://openclipart.org/artist/Firkin) - uploaded on [Openclipart.org](https://openclipart.org/detail/242854/comic-character-316) 

```
############# NANO SYNTAX HIGHLIGHTING START #############

 

## Here is an example for nanorc files.

##

syntax "Nanorc" "\.?nanorc$"

comment "#"

 

## Possible errors and parameters

icolor brightred "^[[:space:]]*((un)?set|include|syntax|i?color).*$"

## Colors

icolor black " black"

icolor red " red"

icolor green " green"

icolor yellow " yellow"

icolor blue " blue"

icolor magenta " magenta"

icolor cyan " cyan"

icolor white " white"

icolor normal " normal"

icolor brightblack " brightblack"

icolor brightred " brightred"

icolor brightgreen " brightgreen"

icolor brightyellow " brightyellow"

icolor brightblue " brightblue"

icolor brightmagenta " brightmagenta"

icolor brightcyan " brightcyan"

icolor brightwhite " brightwhite"

icolor normal " normal"

icolor ,black ",black "

icolor ,red ",red "

icolor ,green ",green "

icolor ,yellow ",yellow "

icolor ,blue ",blue "

icolor ,magenta ",magenta "

icolor ,cyan ",cyan "

icolor ,white ",white "

icolor ,normal ",normal "

icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="

icolor yellow "^[[:space:]]*(set|unset)[[:space:]]+(errorcolor|functioncolor|keycolor|numbercolor|selectedcolor|statuscolor|stripecolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"

 

## Keywords

icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backupdir|boldtext|brackets|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|errorcolor|fill|functioncolor|guidestripe|historylog|jumpyscrolling|keycolor|linenumbers|locking|matchbrackets|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nopauses|nowrap|numbercolor|operatingdir|positionlog|preserve|punct|quickblank|quotestr|rawsequences|rebinddelete|regexp|selectedcolor|showcursor|smarthome|smooth|softwrap|speller|statuscolor|stripecolor|suspend|tabsize|tabstospaces|tempfile|titlecolor|trimblanks|unix|view|whitespace|wordbounds|wordchars|zap)\>"

icolor green "^[[:space:]]*(bind|set|unset|syntax|header|include|magic)\>"

## Strings

icolor white ""(\\.|[^"])*""

## Comments

icolor brightblue "^[[:space:]]*#.*$"

icolor cyan "^[[:space:]]*##.*$"

 

## Trailing whitespace

icolor ,green "[[:space:]]+$"

 

############# NANO SYNTAX SETTINGS FIN #############
```


## Getting there 🐌

I got help when it came to creating my `.nanorc` file too. I went to these two sites:

- [NANORC (nano-editor.org)](https://www.nano-editor.org/)

- [Some Useful GNU nano Settings (bash-prompt.net)](https://bash-prompt.net/guides/nanorc-settings/)

I especially ripped from [bash-prompt.net](https://bash-prompt.net/guides/nanorc-settings/) (THANK YOU!!!!). [Bash-prompt.net](https://bash-prompt.net/guides/nanorc-settings/) made it easier to understand [nanorc-editor.org](https://www.nano-editor.org/dist/v2.9/nanorc.5.html) site and helped me to add the set mouse option to it. As I go, I'll look to add more options, that make sense to me.

```
############# NANO SETTINGS START #############

 

# Non-default settings

set atblanks        # wrap line at blanks.

set cutfromcursor   # CTRL+K cuts from cursor position to end of line.

#set nohelp          # Disable the help information (CTRL+G to view the help screen).

set softwrap        # Enable softwrap of lines.

set suspend         # Enables CTRL+Z to suspend nano.

set tabsize 4       # Sets tab-to-spaces size to 4.

set tabstospaces    # Converts TAB key press to spaces.

include "/usr/share/nano/*.nanorc" # Enables the syntax highlighting.

include "~/.config/nano/Syntax_config.nanorc" # Enables the syntax highlighting. Custom syntax - user

set speller "aspell -x -c"         # Sets what spelling utility to use.

set constantshow    # Displays useful information e.g. line number and position in the bottom bar.

set linenumbers     # Lines are numbered.

set casesensitive   # Case insensitive search.

set historylog      # Save the last 100 history searches for later use.

set positionlog     # Saves the cursor position between editing sessions.

set zap             # Allows you to highlight text (CTRL+SHIFT+ARROW) and delete it with backspace.

set autoindent      # A new line will have the same number of leading spaces as the previous one.

set indicator       # Displays a scroll bar on the right that shows the position and size of the current view port.

set minibar         # Displays file name and other information in the bottom bar. Removes top bar.

set mouse           # . When enabled, mouse clicks can be used to place the cursor, set the mark (with a double click), and execute shortcuts.

 

# Enable and set a working backup directory

set backup                              # Creates backups of your current file.

set backupdir "~/.cache/nano/backups/"  # The location of the backups.

 

# Shortcut key bindings

bind ^C copy main       # CTRL+C - Copy

bind ^V paste all       # CTRL+V - Past

bind ^F whereis all     # CTRL+F - Find

bind ^S savefile main   # CTRL+S - Save

 

############# NANO GENERAL SETTINGS FIN #############
```


## Realization💡

Now, things are running smooth, at least to me 🤞 Welp, too soon man! 😂 I spoke to darn soon 🤣

So, if I hit `CTRL+X` to exit after making changes to whatever I'm
working on in nano during that buffer messaging, it seems, to me, that nano froze as I was still seeing that buffer message, as in screenshot.

Actually, nano was waiting on this dodo 🦤 It wasn't frozen 🥶. All I had to do was press `(Y)` as I usually do when I exit after making changes to something in `nano` and then `nano` asking me if I wanted to `apply`/`save` the changes by selecting `(Y)es` or `(N)o` before completely exiting `nano`.


![A screenshot of nano editor opened in the terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugsd79fg7p5rw7q2lpas.png)

Don't know why I was getting this buffer message/warning/info
though... I made a note of it as something seen 👀🤨. I don't think it's from the customization...!?


![A child with his hand on his head Description automatically
generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs3y9tzwk9jwzca3wraa.png) Image by [Hanna Kovalchuk](https://pixabay.com/users/annakovalchuk-5692419/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2736655) from [Pixabay](https://pixabay.com/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=2736655)

Actually, yeah, my bad, it is from the customization. I enabled `set nohelp`. I realized this when I spun up another VM and customized `nano` there too. So, I disabled it by commenting it out `#set nohelp` or, If I was inclined, I would just not include the option at all ~~`set nohelp`~~.

While going through the config file, I found out that the help can be accessed by hitting `CTRL-G`. I might need to put that down on a post-it notes somewhere 🧐🤣 As much as the help menu's been at the bottom, there, I got so used to it that I didn't notice it until it wasn't there anymore 😂 and in looking to getting it back I learned something new by doing this exercise.

I'm glad, now I know that I get full access to greater definition right at my fingertips, literally 😁🙌 I don't always have to go online to find the info.


![Screenshot of nano settings with a red conversation box](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kaj36y0bq9g0vsy2s79i.png)


## The story of the aspell

As an aside, I remembered that `set speller "aspell -x -c"`, was part of the `.nanorc` config from [bash-promt.net](https://bash-prompt.net/guides/nanorc-settings/) too. [Elliot Cooper] (https://elliotcooper.com/), the person to whom the site belongs, and he did mention something about installing and setting up [GNU Aspel](http://aspell.net/), no instructions though 😁 So, I went to [GNU Aspel](http://aspell.net/)'s site, and they do have an [Appendix](http://aspell.net/man-html/Installing.html#Installing) just on installing... 🧐😭

So, yeah, no [.deb](https://wiki.debian.org/deb) file, no [curl](https://developer.ibm.com/articles/what-is-curl-command/)/[wget](https://linuxize.com/post/wget-command-examples/), no [apt repository](https://www.digitalocean.com/community/tutorials/what-is-apt) that they maintain. OK, cool 😎 no problem. I'll keep looking on [Ubuntu](https://ubuntu.com/download) side to see if [Ubuntu](https://ubuntu.com/download) has something 😁 you know. I could see that [GNU Aspel](http://aspell.net/)'s appendix does seem to have a recipe for how to `make` it myself if I wanted to go that route, as I pointed out earlier, however, since I have [Ubuntu](https://ubuntu.com/), I kept stomping the pavement and then it happened, I was able to find `sudo apt -y install aspell aspell-en` instead 😊🙌


![A group of people standing together Description automatically
generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ofzboq6r7v1gbbqnl3b.jpg) Photo by Helena Lopes on [Pexels.com](https://www.pexels.com/photo/anonymous-friends-standing-together-at-sunset-in-mountains-4453153/)


## Curiosity didn't kill the cat 😼

I had to do it 😂🤣!! I went and I looked to see if another language was available for download, and sure enough [Ubuntu](https://ubuntu.com/download) had another one for download, for [GNU Aspel](https://ftp.gnu.org/) 🙌


![Screenshot of ubuntu terminal search of aspell language afrikaans](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vd52qc5u5ymf78yc849.png)


`sudo apt search aspell-af #Afrikaans`


Yes, I kept the curiosity going 😂, that ain't going away man. So, I looked to see if [GNU Aspel](https://ftp.gnu.org/) had [other languages](https://ftp.gnu.org/gnu/aspell/dict/0index.html) in general and yes, that they do. Now, I don't know if all of them are available on [Ubuntu](https://ubuntu.com/download) for download from their apt repository, as all I needed was English. Wasn't that curious I guess 🤣😂


![A screenshot of some of the available Aspell dictionaries](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzgpyxfo9eue9j07lb71.png)

Once I downloaded the dictionary of my choice, I evaluated it by opening one of my `.nanorc` files and pressing `F12` to fire up speller, sadly no autosuggestions like Microsoft Word or programs like that. It needs initial user interaction 🫤🤷 Ok, now that I see `aspell` and now know it's working!


![Screenshot of Aspell suggestion after pressing F12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zuzjzpw5i386sx6sdvi.png)


## Fin 🙋‍♂️

I'm satisfied with the outcome 🙌😁


![A person holding a glass of liquid Description automatically generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tur4m4xuu0b4njfbw9dn.jpg) Photo by Terricks Noah on [Pexels.com](https://www.pexels.com/photo/woman-wears-white-lace-bathrobe-holds-shot-glass-936571/)


Hope this helps!

Thank you,

Blogging out! 😎😊✌️