个人工具

“UbuntuHelp:Nano”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/Nano}} {{Languages|UbuntuHelp:Nano}} Parent page: Programming Applications '''Nano Homepage:''' http://www.nano-edi...)
 
 
(未显示同一用户的5个中间版本)
第2行: 第2行:
 
{{Languages|UbuntuHelp:Nano}}
 
{{Languages|UbuntuHelp:Nano}}
 
Parent page: [[UbuntuHelp:Programming| Programming Applications]]
 
Parent page: [[UbuntuHelp:Programming| Programming Applications]]
 
+
'''Nano Homepage:''' http://www.nano-editor.org/ <<BR>>
 
+
'''Documentation:''' http://www.nano-editor.org/docs.php <<BR>>
 
+
'''Ubuntu Repository: ''' Main  <<BR>>
'''Nano Homepage:''' http://www.nano-editor.org/ <br>
+
'''Package Name:''' nano  <<BR>>
'''Documentation:''' http://www.nano-editor.org/docs.php <br>
+
'''Ubuntu Repository: ''' Main  <br>
+
'''Package Name:''' nano  <br>
+
 
'''Version in Repository:''' 1.3.10 (As of 2006-12-02 in Ubuntu 6.06 LTS)
 
'''Version in Repository:''' 1.3.10 (As of 2006-12-02 in Ubuntu 6.06 LTS)
 
 
=== Introduction ===
 
=== Introduction ===
 
 
[http://www.gnu.org/ GNU] nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files. It was originally created as a free replacement for the non-free Pico editor. Pico is the terminal-based editor used in the Pine email suite from the University of Washington.
 
[http://www.gnu.org/ GNU] nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files. It was originally created as a free replacement for the non-free Pico editor. Pico is the terminal-based editor used in the Pine email suite from the University of Washington.
 
 
Nano can be used in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]] or at the [http://en.wikipedia.org/wiki/Computer_console system console].
 
Nano can be used in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]] or at the [http://en.wikipedia.org/wiki/Computer_console system console].
 
 
Basic use of nano is covered here. If you want to learn more advanced techniques such as the use of multiple buffers or syntax highlighting of code, see the [http://www.nano-editor.org/dist/v1.3/faq.html The GNU nano editor FAQ].
 
Basic use of nano is covered here. If you want to learn more advanced techniques such as the use of multiple buffers or syntax highlighting of code, see the [http://www.nano-editor.org/dist/v1.3/faq.html The GNU nano editor FAQ].
 
 
=== Installing Nano ===
 
=== Installing Nano ===
 
 
Nano is part of the standard Ubuntu installation, and should be on your system already. If for some reason it's not, use your favorite package manager to install it. The example below shows how to install the package <code><nowiki>nano</nowiki></code> from the command line using the ''apt-get'' program. The text that you type is in bold.
 
Nano is part of the standard Ubuntu installation, and should be on your system already. If for some reason it's not, use your favorite package manager to install it. The example below shows how to install the package <code><nowiki>nano</nowiki></code> from the command line using the ''apt-get'' program. The text that you type is in bold.
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;font-family: Monospace;border: 1pt solid black;width:80%;margin-left:1em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|jeffsch@mandela:~ '''sudo apt-get install nano'''
 
|jeffsch@mandela:~ '''sudo apt-get install nano'''
 
|}
 
|}
 
 
When prompted, type in your regular user password, the one you use to log onto Ubuntu with.
 
When prompted, type in your regular user password, the one you use to log onto Ubuntu with.
 
 
=== Using Nano ===
 
=== Using Nano ===
 
 
Nano is a terminal-based command-line program. Although not complicated or difficult to use, it is different than a GUI-based text editor such as ''gedit''. The two main features that differ are the short-cut key combinations and the use of a mouse.
 
Nano is a terminal-based command-line program. Although not complicated or difficult to use, it is different than a GUI-based text editor such as ''gedit''. The two main features that differ are the short-cut key combinations and the use of a mouse.
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;border: 1pt solid black;width:80%;margin-left:2em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|'''Note'''
 
|'''Note'''
第42行: 第28行:
 
|This discussion refers specifically to the use of nano in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]]. Using nano at the [http://en.wikipedia.org/wiki/Computer_console system console] is almost identical, with the main difference being the use of the mouse.
 
|This discussion refers specifically to the use of nano in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]]. Using nano at the [http://en.wikipedia.org/wiki/Computer_console system console] is almost identical, with the main difference being the use of the mouse.
 
|}
 
|}
 
 
==== Starting Nano ====
 
==== Starting Nano ====
 
 
To start nano with an empty file, open a terminal window and at the command-line type "nano" (without the quotes). For example:
 
To start nano with an empty file, open a terminal window and at the command-line type "nano" (without the quotes). For example:
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;font-family: Monospace;border: 1pt solid black;width:80%;margin-left:1em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|jeffsch@mandela:~ '''nano'''
 
|jeffsch@mandela:~ '''nano'''
 
|}
 
|}
 
 
To open an existing file for editing, type "nano ''filename''" where ''filename'' is the name of the existing file. For example, to open the file that contains the list of most recently issued commands, make sure you are in your home directory, and at the command line type "nano .bash_history" as in the following example:
 
To open an existing file for editing, type "nano ''filename''" where ''filename'' is the name of the existing file. For example, to open the file that contains the list of most recently issued commands, make sure you are in your home directory, and at the command line type "nano .bash_history" as in the following example:
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;font-family: Monospace;border: 1pt solid black;;width:80%;margin-left:1em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|jeffsch@mandela:~ '''nano .bash_history'''
 
|jeffsch@mandela:~ '''nano .bash_history'''
 
|}
 
|}
 
 
In the above example, if the file ''.bash_history'' does not exist in your current directory, nano will start a new blank file and use ''.bash_history'' as the name for it.
 
In the above example, if the file ''.bash_history'' does not exist in your current directory, nano will start a new blank file and use ''.bash_history'' as the name for it.
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;border:  1pt solid black;width:80%;margin-left:2em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|'''Caution'''
 
|'''Caution'''
 
|-
 
|-
|Line wrap is on by default. When line wrap is on, nano inserts end-of-line characters into your file when it wraps lines to fit the width of the terminal window. Only lines that you type or paste into the window are wrapped. Existing long lines are not wrapped until you add new text to the line or use the '''Ctrl-J''' key combination to justify the current paragraph.<br><br>If you are using nano to edit configuration files, you probably do not want line wrapping to be on. To start nano with line wrapping off, use the -w switch, as in the following example:
+
|Line wrap is on by default. When line wrap is on, nano inserts end-of-line characters into your file when it wraps lines to fit the width of the terminal window. Only lines that you type or paste into the window are wrapped. Existing long lines are not wrapped until you add new text to the line or use the '''Ctrl-J''' key combination to justify the current paragraph.>>If you are using nano to edit configuration files, you probably do not want line wrapping to be on. To start nano with line wrapping off, use the -w switch, as in the following example:
 
|-
 
|-
 
|jeffsch@mandela:~ '''nano -w .bashrc'''
 
|jeffsch@mandela:~ '''nano -w .bashrc'''
 
|}
 
|}
 
 
==== Screen Layout ====
 
==== Screen Layout ====
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;">'''Figure 1: Default nano screen layout'''<br><br>https://help.ubuntu.com/community/Nano?action=AttachFile&do=get&target=nano-screen-small.png%7C%
+
|'''Figure 1: Default nano screen layout'''>>https://help.ubuntu.com/community/Nano?action=AttachFile&do=get&target=nano-screen-small.png
 
|}
 
|}
 
 
The default nano screen layout is as shown in Figure 1. The bottom two lines show the key combinations for common operations. The ^ symbol represents the Control key on your keyboard. For example, use the Ctrl-G key combination to display a basic introduction to nano and its default screen layout.
 
The default nano screen layout is as shown in Figure 1. The bottom two lines show the key combinations for common operations. The ^ symbol represents the Control key on your keyboard. For example, use the Ctrl-G key combination to display a basic introduction to nano and its default screen layout.
 
 
The screen fonts and background colours are determined by your terminal settings. And when you resize the terminal window, nano adjusts itself accordingly.
 
The screen fonts and background colours are determined by your terminal settings. And when you resize the terminal window, nano adjusts itself accordingly.
 
 
Long lines that are not wrapped to fit the window are indicated by the $ symbol at the extreme right edge of the terminal window. The $ symbol is not part of your file; it just tells you that the line of text is too long to be displayed in the terminal.
 
Long lines that are not wrapped to fit the window are indicated by the $ symbol at the extreme right edge of the terminal window. The $ symbol is not part of your file; it just tells you that the line of text is too long to be displayed in the terminal.
 
 
==== Using The Mouse ====
 
==== Using The Mouse ====
 
 
By default, mouse services are provided by the terminal window. The mouse works almost the same as in a [http://wordnet.princeton.edu/perl/webwn?s=gui GUI] editor. You can highlight text, right-click to copy and paste, and use the middle mouse button for pasting text from the buffer. However, when you use the middle mouse button to paste text, the text is pasted at the current cursor location, not at the mouse pointer location. Other limitations exist. For example, you cannot use the mouse to cut or delete text, nor can you use the mouse to scroll through the file.
 
By default, mouse services are provided by the terminal window. The mouse works almost the same as in a [http://wordnet.princeton.edu/perl/webwn?s=gui GUI] editor. You can highlight text, right-click to copy and paste, and use the middle mouse button for pasting text from the buffer. However, when you use the middle mouse button to paste text, the text is pasted at the current cursor location, not at the mouse pointer location. Other limitations exist. For example, you cannot use the mouse to cut or delete text, nor can you use the mouse to scroll through the file.
 
 
Nano has its own built-in mouse services, but they are limited. They provide only the ability to move the cursor to the point where you click, and to mark the beginning and end of a section of text. Use the '''Alt-M''' key combination to toggle between using the terminal's mouse services and nano's built-in mouse services.  
 
Nano has its own built-in mouse services, but they are limited. They provide only the ability to move the cursor to the point where you click, and to mark the beginning and end of a section of text. Use the '''Alt-M''' key combination to toggle between using the terminal's mouse services and nano's built-in mouse services.  
 
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;border: 1pt solid black;width:80%;margin-left:2em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|'''Note'''
 
|'''Note'''
第98行: 第68行:
 
|If you are using nano at the [http://en.wikipedia.org/wiki/Computer_console system console], you must have ''gpm'' installed and running before using the mouse. The <code><nowiki>gpm</nowiki></code> package is in the Universe repository.
 
|If you are using nano at the [http://en.wikipedia.org/wiki/Computer_console system console], you must have ''gpm'' installed and running before using the mouse. The <code><nowiki>gpm</nowiki></code> package is in the Universe repository.
 
|}
 
|}
 
 
==== Using the Keyboard ====
 
==== Using the Keyboard ====
 
 
Typing at the keyboard will insert text at the current cursor location. The Page Up and Page Down keys, the Arrow keys, and the Insert key and Delete key all work as in most other text editors. If you are at a keyboard that does not have these keys, you can use alternative Ctrl-key combinations. They are listed in nano's online help, accessible with the '''Ctrl-G''' key combination.
 
Typing at the keyboard will insert text at the current cursor location. The Page Up and Page Down keys, the Arrow keys, and the Insert key and Delete key all work as in most other text editors. If you are at a keyboard that does not have these keys, you can use alternative Ctrl-key combinations. They are listed in nano's online help, accessible with the '''Ctrl-G''' key combination.
 
 
Copy, paste, and cut operations are available, but they do not use the same Ctrl-key sequences as in most GUI editors. See the '''Editing Text''' section for more information.
 
Copy, paste, and cut operations are available, but they do not use the same Ctrl-key sequences as in most GUI editors. See the '''Editing Text''' section for more information.
 
 
==== Opening, Saving, and Closing Files ====
 
==== Opening, Saving, and Closing Files ====
 
 
You can open a file for editing when you start nano, as discussed in the Starting Nano section. This section shows you how to open a file when nano is already started.
 
You can open a file for editing when you start nano, as discussed in the Starting Nano section. This section shows you how to open a file when nano is already started.
 
 
===== Opening Files =====
 
===== Opening Files =====
 
 
Open a file with the Read File command, '''Ctrl-R'''. The Read File command inserts a file from disk at the current cursor location.
 
Open a file with the Read File command, '''Ctrl-R'''. The Read File command inserts a file from disk at the current cursor location.
 
 
When prompted, type the name of the file you want to open, or use the '''Ctrl-T''' key combination to use nano's built-in file browser to navigate to the file you want to open.
 
When prompted, type the name of the file you want to open, or use the '''Ctrl-T''' key combination to use nano's built-in file browser to navigate to the file you want to open.
 
 
If a file is already open, nano will insert the new file into it at the current cursor location; it will not close the existing file, nor will it open a new screen for the new file.
 
If a file is already open, nano will insert the new file into it at the current cursor location; it will not close the existing file, nor will it open a new screen for the new file.
 
 
===== Save and Save As =====
 
===== Save and Save As =====
 
 
Save and Save As are both accomplished with the Write Out command, '''Ctrl-O'''.
 
Save and Save As are both accomplished with the Write Out command, '''Ctrl-O'''.
 
 
When prompted, press enter to accept the existing file name. To save as another file name, type in the new name and press Enter, or use the '''Ctrl-T''' key combination to use nano's built-in file browser.
 
When prompted, press enter to accept the existing file name. To save as another file name, type in the new name and press Enter, or use the '''Ctrl-T''' key combination to use nano's built-in file browser.
 
 
===== Closing Files =====
 
===== Closing Files =====
 
 
Close a file with the '''Ctrl-X''' key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
 
Close a file with the '''Ctrl-X''' key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
 
 
Closing a file also closes nano.
 
Closing a file also closes nano.
 
 
==== Editing Text ====
 
==== Editing Text ====
 
 
As is normal in most text editors, text that you type into nano is inserted at the current cursor position. The Delete and Backspace keys also work the same as in other editors.
 
As is normal in most text editors, text that you type into nano is inserted at the current cursor position. The Delete and Backspace keys also work the same as in other editors.
 
+
Use the '''Alt-6''' key combination to copy text to the "cut buffer". Similarly, use the '''Ctrl-K''' key combination to delete text (it is cut to the "cut buffer"). If no text is marked, these two commands copy or cut the entire line of text.
Version 1.3 of nano does not have direct support for copy operations. Instead, you cut a piece of text, then before moving to a new location in the file, you insert the cut text back into its original location.
+
Use the  '''Ctrl-U''' key combination to paste the text in the "cut buffer" into the file.
 
+
To cut or copy specific text, you must first mark the start and end points of the text you want to select. You can do this with the either keyboard or the mouse, but to use the mouse for marking you must first turn on nano's built-in mouse services.
Use the '''Ctrl-K''' key combination to delete an entire line of text, and the  '''Ctrl-U''' key combination to paste the deleted line back into the file.
+
 
+
To cut and paste more than one line at a time, you must first mark the start and end points of the text you want to select. You can do this with the either keyboard or the mouse, but to use the mouse for marking you must first turn on nano's built-in mouse services.
+
 
+
 
To use the keyboard to select text, move the cursor to the start of the text you want to select, press the '''Alt-A''' key combination to mark the start, then move the cursor to the end of the section you want to select.
 
To use the keyboard to select text, move the cursor to the start of the text you want to select, press the '''Alt-A''' key combination to mark the start, then move the cursor to the end of the section you want to select.
 
 
To use the mouse to mark the start of a selection, first make sure that nano's built-in mouse services are turned on. Use the '''Alt-M''' key combination to toggle between nano's mouse and the terminal's mouse. Click on the location where you want to mark the start of the selection, move to the end of the section you want to select, and click the mouse again. You might need to use the keyboard to scroll the screen up or down because nano does not support scrolling with the mouse.
 
To use the mouse to mark the start of a selection, first make sure that nano's built-in mouse services are turned on. Use the '''Alt-M''' key combination to toggle between nano's mouse and the terminal's mouse. Click on the location where you want to mark the start of the selection, move to the end of the section you want to select, and click the mouse again. You might need to use the keyboard to scroll the screen up or down because nano does not support scrolling with the mouse.
 
+
Once you have marked the beginning and end of text, the '''Alt-6''' and '''Ctrl-K''' key combinations can be used to copy or cut it, respectively.
Once you have marked the beginning and end of text, the '''Ctrl-K''' key combination can be used to cut it.
+
 
+
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"
|<tablestyle="background-color: #f0eee6;border: 1pt solid black;width:80%;margin-left:2em;" style="border: none;padding:0;">
+
|
 
|-
 
|-
 
|'''Note'''
 
|'''Note'''
 
|-
 
|-
|Text that is cut with the '''Ctrl-K''' key combination is placed into nano's internal cut buffer and can only be pasted back into the current nano session. The text is not available for pasting into other windows or programs.
+
|Text copied or cut into nano's internal "cut buffer" can only be pasted back into the current nano session. The text is not available for pasting into other windows or programs.
 
|}
 
|}
 
+
If you are using nano in a [[UbuntuHelp:[[UbuntuHelp:HowToUseTheTerminal|HowToUseTheTerminal]]|terminal window]] you can use the mouse to copy and paste text to and from other windows on your desktop. You cannot use the mouse to cut or delete text.  
If you are using nano in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]] you can use the mouse to copy and paste text to and from other windows on your desktop. You cannot use the mouse to cut or delete text.  
+
 
+
 
==== Quitting Nano ====
 
==== Quitting Nano ====
 
 
To quit nano, use the '''Ctrl-X''' key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
 
To quit nano, use the '''Ctrl-X''' key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.
 
 
=== Resources ===
 
=== Resources ===
 
 
* The GNU nano Homepage: http://www.nano-editor.org/
 
* The GNU nano Homepage: http://www.nano-editor.org/
 
* GNU nano FAQ: http://www.nano-editor.org/dist/v1.3/faq.html
 
* GNU nano FAQ: http://www.nano-editor.org/dist/v1.3/faq.html
 
* GNU nano Documentation: http://www.nano-editor.org/docs.php
 
* GNU nano Documentation: http://www.nano-editor.org/docs.php
* Basic Introduction to Emacs: EmacsHowto
+
* Basic Introduction to Emacs: [[UbuntuHelp:EmacsHowto|EmacsHowto]]
* Introduction to Vim: VimHowto
+
* Introduction to Vim: [[UbuntuHelp:VimHowto|VimHowto]]
* Using a terminal and the command line: HowToUseTheTerminal and CommandlineHowto
+
* Using a terminal and the command line: [[UbuntuHelp:HowToUseTheTerminal|HowToUseTheTerminal]] and [[UbuntuHelp:CommandlineHowto|CommandlineHowto]]
 
+
----
 
+
UserDocumentation
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年5月12日 (二) 18:10的最新版本

Parent page: Programming Applications Nano Homepage: http://www.nano-editor.org/ <
> Documentation: http://www.nano-editor.org/docs.php <
> Ubuntu Repository: Main <
> Package Name: nano <
> Version in Repository: 1.3.10 (As of 2006-12-02 in Ubuntu 6.06 LTS)

Introduction

GNU nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is easy to learn and use. Nano is ideal for making small changes to existing configuration files or for writing short plain text files. It was originally created as a free replacement for the non-free Pico editor. Pico is the terminal-based editor used in the Pine email suite from the University of Washington. Nano can be used in a terminal window or at the system console. Basic use of nano is covered here. If you want to learn more advanced techniques such as the use of multiple buffers or syntax highlighting of code, see the The GNU nano editor FAQ.

Installing Nano

Nano is part of the standard Ubuntu installation, and should be on your system already. If for some reason it's not, use your favorite package manager to install it. The example below shows how to install the package nano from the command line using the apt-get program. The text that you type is in bold.

jeffsch@mandela:~ sudo apt-get install nano

When prompted, type in your regular user password, the one you use to log onto Ubuntu with.

Using Nano

Nano is a terminal-based command-line program. Although not complicated or difficult to use, it is different than a GUI-based text editor such as gedit. The two main features that differ are the short-cut key combinations and the use of a mouse.

Note
This discussion refers specifically to the use of nano in a terminal window. Using nano at the system console is almost identical, with the main difference being the use of the mouse.

Starting Nano

To start nano with an empty file, open a terminal window and at the command-line type "nano" (without the quotes). For example:

jeffsch@mandela:~ nano

To open an existing file for editing, type "nano filename" where filename is the name of the existing file. For example, to open the file that contains the list of most recently issued commands, make sure you are in your home directory, and at the command line type "nano .bash_history" as in the following example:

jeffsch@mandela:~ nano .bash_history

In the above example, if the file .bash_history does not exist in your current directory, nano will start a new blank file and use .bash_history as the name for it.

Caution
Line wrap is on by default. When line wrap is on, nano inserts end-of-line characters into your file when it wraps lines to fit the width of the terminal window. Only lines that you type or paste into the window are wrapped. Existing long lines are not wrapped until you add new text to the line or use the Ctrl-J key combination to justify the current paragraph.>>If you are using nano to edit configuration files, you probably do not want line wrapping to be on. To start nano with line wrapping off, use the -w switch, as in the following example:
jeffsch@mandela:~ nano -w .bashrc

Screen Layout

Figure 1: Default nano screen layout>>Nano?action=AttachFile&do=get&target=nano-screen-small.png

The default nano screen layout is as shown in Figure 1. The bottom two lines show the key combinations for common operations. The ^ symbol represents the Control key on your keyboard. For example, use the Ctrl-G key combination to display a basic introduction to nano and its default screen layout. The screen fonts and background colours are determined by your terminal settings. And when you resize the terminal window, nano adjusts itself accordingly. Long lines that are not wrapped to fit the window are indicated by the $ symbol at the extreme right edge of the terminal window. The $ symbol is not part of your file; it just tells you that the line of text is too long to be displayed in the terminal.

Using The Mouse

By default, mouse services are provided by the terminal window. The mouse works almost the same as in a GUI editor. You can highlight text, right-click to copy and paste, and use the middle mouse button for pasting text from the buffer. However, when you use the middle mouse button to paste text, the text is pasted at the current cursor location, not at the mouse pointer location. Other limitations exist. For example, you cannot use the mouse to cut or delete text, nor can you use the mouse to scroll through the file. Nano has its own built-in mouse services, but they are limited. They provide only the ability to move the cursor to the point where you click, and to mark the beginning and end of a section of text. Use the Alt-M key combination to toggle between using the terminal's mouse services and nano's built-in mouse services.

Note
If you are using nano at the system console, you must have gpm installed and running before using the mouse. The gpm package is in the Universe repository.

Using the Keyboard

Typing at the keyboard will insert text at the current cursor location. The Page Up and Page Down keys, the Arrow keys, and the Insert key and Delete key all work as in most other text editors. If you are at a keyboard that does not have these keys, you can use alternative Ctrl-key combinations. They are listed in nano's online help, accessible with the Ctrl-G key combination. Copy, paste, and cut operations are available, but they do not use the same Ctrl-key sequences as in most GUI editors. See the Editing Text section for more information.

Opening, Saving, and Closing Files

You can open a file for editing when you start nano, as discussed in the Starting Nano section. This section shows you how to open a file when nano is already started.

Opening Files

Open a file with the Read File command, Ctrl-R. The Read File command inserts a file from disk at the current cursor location. When prompted, type the name of the file you want to open, or use the Ctrl-T key combination to use nano's built-in file browser to navigate to the file you want to open. If a file is already open, nano will insert the new file into it at the current cursor location; it will not close the existing file, nor will it open a new screen for the new file.

Save and Save As

Save and Save As are both accomplished with the Write Out command, Ctrl-O. When prompted, press enter to accept the existing file name. To save as another file name, type in the new name and press Enter, or use the Ctrl-T key combination to use nano's built-in file browser.

Closing Files

Close a file with the Ctrl-X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file. Closing a file also closes nano.

Editing Text

As is normal in most text editors, text that you type into nano is inserted at the current cursor position. The Delete and Backspace keys also work the same as in other editors. Use the Alt-6 key combination to copy text to the "cut buffer". Similarly, use the Ctrl-K key combination to delete text (it is cut to the "cut buffer"). If no text is marked, these two commands copy or cut the entire line of text. Use the Ctrl-U key combination to paste the text in the "cut buffer" into the file. To cut or copy specific text, you must first mark the start and end points of the text you want to select. You can do this with the either keyboard or the mouse, but to use the mouse for marking you must first turn on nano's built-in mouse services. To use the keyboard to select text, move the cursor to the start of the text you want to select, press the Alt-A key combination to mark the start, then move the cursor to the end of the section you want to select. To use the mouse to mark the start of a selection, first make sure that nano's built-in mouse services are turned on. Use the Alt-M key combination to toggle between nano's mouse and the terminal's mouse. Click on the location where you want to mark the start of the selection, move to the end of the section you want to select, and click the mouse again. You might need to use the keyboard to scroll the screen up or down because nano does not support scrolling with the mouse. Once you have marked the beginning and end of text, the Alt-6 and Ctrl-K key combinations can be used to copy or cut it, respectively.

Note
Text copied or cut into nano's internal "cut buffer" can only be pasted back into the current nano session. The text is not available for pasting into other windows or programs.

If you are using nano in a [[UbuntuHelp:HowToUseTheTerminal|terminal window]] you can use the mouse to copy and paste text to and from other windows on your desktop. You cannot use the mouse to cut or delete text.

Quitting Nano

To quit nano, use the Ctrl-X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.

Resources