DEV Community

Shafi
Shafi

Posted on • Originally published at shafi.live

Customize Nano Text Editor

Nano is a great text editor that is available in every linux distros by default. Here's a few configs that would make your experience with nano even better!

To use the features listed below, you need to edit the .nanorc file in your home directory.
You can open the terminal and write nano .nanorc to access the configurations file.

Position Cursor With Mouse Click

Mouse clicks can be used to place the cursor, set the mark (with a double click), and execute shortcuts. Text can still be selected through dragging by holding down the Shift key.

set mouse
Enter fullscreen mode Exit fullscreen mode

Set the Tab Size

Set the size (width) of a tab to number columns. The value of number must be greater than 0. The default value is 8.

set tabsize 2
Enter fullscreen mode Exit fullscreen mode

Replace Tabs With Spaces

set tabstospaces
Enter fullscreen mode Exit fullscreen mode

Keep Track of Cursor Location for Recently Closed Files

For the 200 most recent files, log the last position of the cursor, and place it at that position again upon reopening such a file.

set positionlog
Enter fullscreen mode Exit fullscreen mode

Wrap Lines

Display over multiple screen rows line that exceed the screen's width. (You can make this soft-wrapping occur at whitespace instead of rudely at the screen's edge, by using atblanks.

set softwrap
set atblanks
Enter fullscreen mode Exit fullscreen mode

Auto Indentation

Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line.

set autoindent
Enter fullscreen mode Exit fullscreen mode

Display Line Numbers

Display line numbers to the left of the text area.

set linenumbers
Enter fullscreen mode Exit fullscreen mode

Display Scrollbars

Display a "scrollbar" on the righthand side of the edit window. It shows the position of the viewport.

set indicator
Enter fullscreen mode Exit fullscreen mode

Top comments (0)