Difference between revisions of "Nano"
(→.nanorc) |
(→.nanorc) |
||
Line 49: | Line 49: | ||
* <code>set undo</code> - Enable undo/redo functionality | * <code>set undo</code> - Enable undo/redo functionality | ||
− | To edit your <code>.nanorc</code> file, run the command <code>nano ~/.nanorc</code> to create/edit the file, save it, then relaunch <code>nano</code> and your options will be enabled. You only need to create the file one time for it to be active for all future sessions. | + | To edit your <code>.nanorc</code> file, run the command <code>nano ~/.nanorc</code> to create/edit the file, save it, then relaunch <code>nano</code> and your options will be enabled. You only need to create the file one time for it to be active for all future sessions. Be sure not to put any blank lines in your <code>.nanorc</code> file! |
More <code>.nanorc</code> options can be found here: https://www.nano-editor.org/dist/v2.1/nanorc.5.html | More <code>.nanorc</code> options can be found here: https://www.nano-editor.org/dist/v2.1/nanorc.5.html |
Latest revision as of 17:43, 24 January 2018
nano
is an open-source text editor that can be used to write programs.
Background
Pine
was a text-based email client written in 1989 and released publicly in 1992 by the University of Washington. For writing emails, Pine
had an integrated text editor called Pico
-- short for Pine composition. Due to how easy Pico
was to use, people began using it outside of Pine
for more general things such as writing documents and code. Unfortunately, the licensing terms for Pico
were not acceptable for the open-source software movement, and thus an open-source clone, nano
, was created.
Pros
- Between
emacs
,vim
, andnano
,nano
is likely the easiest editor for first-time users - Simple key combinations for commands
- Features include:
- Syntax highlighting for programming
- Cut & paste
- File insertion
- Position saving between sessions
- Word wrap
- Adjustable scrolling
- Find & replace
- Line/column display
- Automatic indentation
- Jump to line/column
Cons
Using nano
-
nano
- startsnano
with a blank file -
nano filename
- startsnano
and opens filename if it exists, otherwise it will be blank and will default to saving asfilename
Useful key combinations
- ctrl-x: exit (will prompt to save if file was changed & not saved yet)
- ctrl-o: save
- ctrl-w: find
- ctrl-w then ctrl-y: go to top of file
- ctrl-w then ctrl-v: go to bottom of file
- ctrl-w then ctrl-r: find & replace
- ctrl-k: cut line (can cut multiple lines)
- ctrl-u: paste line (can paste multiple times)
- ctrl-c: report location of the cursor
.nanorc
.nanorc
refers to a file that can be placed in your home directory that will enable certain features in nano
by default. By default nano
will have few, if any, options enabled. All of these options can be enabled via flags when launching nano
, or the .nanorc
file can be created/modified such that the options do not have to be included manually.
For example, nano -S file.cpp
will open file.cpp
with smooth scrolling enabled, however the set smooth
option can be placed in .nanorc
so that nano file.cpp
without the flag will still have smooth scrolling enabled.
Some useful .nanorc
features are as follows:
-
set smooth
- To enable smooth scrolling. By default, when scrolling down or up past the viewable area,nano
will load multiple lines. If you want to have it only go up or down by 1 line instead, enable this option -
include /usr/share/nano/c.nanorc
- Includes features that enable syntax highlighting in C/C++ -
set tabsize n
- Sets the tab size to n columns instead of the default 8 -
set undo
- Enable undo/redo functionality
To edit your .nanorc
file, run the command nano ~/.nanorc
to create/edit the file, save it, then relaunch nano
and your options will be enabled. You only need to create the file one time for it to be active for all future sessions. Be sure not to put any blank lines in your .nanorc
file!
More .nanorc
options can be found here: https://www.nano-editor.org/dist/v2.1/nanorc.5.html