·Ubuntu」Nano命令

也是昨天的时候用到了nano
是一个建议的编译器
然后找到了一篇很好的博客学习之。
顺便转载过来,

Nano命令指南

今天在输命令时,无意中输入了nano,对这个命令不太熟悉,结果不知道如何才能退出,保存,赶快查了一下资料,原来是这样的啊。

代码 1.1: 打开或新建文件

#nano 文件名

Nano是一种单模式编辑器,你可以直接输入文字。如果你要编辑一个像/etc/fstab一样的配置文件,请使用-w参数,例如:


代码 1.2: 禁用自动换行

#nano -w /etc/fstab

警告:这非常重要。如果在编辑配置文件时忘了加-w参数,可能会导致你的系统无法起动或产生别的异常。

保存和退出

如果你要保存所做的修改,按下Ctrl+O。想要退出,按下Ctrl+X。如果你退出前没有保存所做的修改,它会提示你是否要保存。如果不要,请按N,反之,则按Y。然后它会让你确认要保存的文件名,确认或修改后按Enter即可。

如果你没有修改好而不小心按了保存键,您可以在请求确认文件名时按Ctrl+C来取消。

剪切和粘贴

要剪切一整行,请用Ctrl+K(按住Ctrl不放,再按下K键)。光标所在的行便消失了。要粘贴它,只需把光标移动到您所要粘贴的位置,然后按Ctrl+U即可。要移动多行,只需多按几次Ctrl+K把需要移动内容都剪切下来,然后按一次Ctrl+U就可以把刚剪切的内容全部粘贴上来。

如果你想使用更精确的剪切控制,则需要给文本做标记。移动光标到需要剪切文本的开头,按下Ctrl+6(或者Alt+A)。然后移动光标到待剪切文本的末尾:被做了标记的文本便会反白。要撤消文本标记,只需再按一次Ctrl+6。用Ctrl+K来剪切被标记的文本,用Ctrl+U来粘贴。

搜索特定文字

当你想搜索某特定文字时,只要想成"WhereIs"而不是"Search",事情就简单了。只要按下Ctrl+W,键入你要搜索的字符串,再按Enter就可以了。想再次搜索相同的字符串,可以直接按Alt+W。
注意:在nano帮助文档里,Ctrl-键被表示为一个脱字符(^),因此Ctrl+W被写成了^W,等等。Alt-键被表示为一个M(从"Meta"而来),因此Alt+W被写成了M-W。
 nano 的帮助文档 Main nano help text

 The nano editor is designed to emulate the functionality and ease-of-use of
 the UW Pico text editor.  There are four main sections of the editor.  The top
 line shows the program version, the current filename being edited, and whether
 or not the file has been modified.  Next is the main editor window showing the
 file being edited.  The status line is the third line from the bottom and
 shows important messages.  The bottom two lines show the most commonly used
 shortcuts in the editor.

 The notation for shortcuts is as follows: Control-key sequences are notated
 with a caret (^) symbol and can be entered either by using the Control (Ctrl)
 key or pressing the Escape (Esc) key twice.  Escape-key sequences are notated
 with the Meta (M-) symbol and can be entered using either the Esc, Alt, or
 Meta key depending on your keyboard setup.  Also, pressing Esc twice and then
 typing a three-digit decimal number from 000 to 255 will enter the character
 with the corresponding value.  The following keystrokes are available in the
 main editor window.  Alternative keys are shown in parentheses:

^G      (F1)            Display this help text
^X      (F2)            Close the current file buffer / Exit from nano
^O      (F3)            Write the current file to disk
^J      (F4)            Justify the current paragraph

^R      (F5)            Insert another file into the current one
^W      (F6)            Search for a string or a regular expression
^Y      (F7)            Go to previous screen
^V      (F8)            Go to next screen

^K      (F9)            Cut the current line and store it in the cutbuffer
^U      (F10)           Uncut from the cutbuffer into the current line
^C      (F11)           Display the position of the cursor
^T      (F12)           Invoke the spell checker, if available

M-\     (M-|)           Go to the first line of the file
M-/     (M-?)           Go to the last line of the file
^_      (F13)   (M-G)   Go to line and column number
^\      (F14)   (M-R)   Replace a string or a regular expression
^^      (F15)   (M-A)   Mark text at the cursor position
M-W     (F16)           Repeat last search

M-^     (M-6)           Copy the current line and store it in the cutbuffer
M-}                     Indent the current line
M-{                     Unindent the current line
^F                      Go forward one character
^B                      Go back one character
^Space                  Go forward one word
M-Space                 Go back one word
^P                      Go to previous line
^N                      Go to next line

^A                      Go to beginning of current line
^E                      Go to end of current line
M-(     (M-9)           Go to beginning of paragraph; then of previous paragraph
M-)     (M-0)           Go just beyond end of paragraph; then of next paragraph
M-]                     Go to the matching bracket
M--     (M-_)           Scroll up one line without scrolling the cursor
M-+     (M-=)           Scroll down one line without scrolling the cursor
M-<     (M-,)           Switch to the previous file buffer
M->     (M-.)           Switch to the next file buffer

M-V                     Insert the next keystroke verbatim
^I                      Insert a tab at the cursor position
^M                      Insert a newline at the cursor position
^D                      Delete the character under the cursor
^H                      Delete the character to the left of the cursor
M-T                     Cut from the cursor position to the end of the file

M-J                     Justify the entire file
M-D                     Count the number of words, lines, and characters
^L                      Refresh (redraw) the current screen
^Z                      Suspend the editor (if suspend is enabled)
(M-X)                   Help mode enable/disable
(M-C)                   Constant cursor position display enable/disable
(M-O)                   Use of one more line for editing enable/disable
(M-S)                   Smooth scrolling enable/disable
(M-P)                   Whitespace display enable/disable
(M-Y)                   Color syntax highlighting enable/disable
(M-H)                   Smart home key enable/disable
(M-I)                   Auto indent enable/disable
(M-K)                   Cut to end enable/disable
(M-L)                   Long line wrapping enable/disable
(M-Q)                   Conversion of typed tabs to spaces enable/disable
(M-B)                   Backup files enable/disable
(M-F)                   Multiple file buffers enable/disable
(M-M)                   Mouse support enable/disable
(M-N)                   No conversion from DOS/Mac format enable/disable
(M-Z)                   Suspension enable/disable
(M-$)                   Soft line wrapping enable/disable

 

时间: 2024-12-29 09:16:45

·Ubuntu」Nano命令的相关文章

Ubuntu文本编辑时vi和nano命令的区别(建议使用nano)

vi是Unix世界里极为普遍的全荧幕文书编辑器,几乎可以说任何一台Unix机器都会提供这套软体就像windows的记事本一样. 键入 vi /etc/hosts 进入vi界面,把光标移动到文件未尾.按ESC键进行命令模式,然后输入A,新起一行 输入你要配置的host ,如: 192.168.0.192 photo.dxxf.net . 完成后 按ESC键进行命令模式,输入 :wq (注意需要输入 : )保存退出. 2.用nano命令修改: nano是一个小巧自由,并且友好的编辑器,在大部分lin

nano 命令 linux

用途说明 nano是一个字符终端的文本编辑器,有点像DOS下的editor程序.它比vi/vim要简单得多,比较适合Linux初学者使用.某些Linux发行版的默认编辑器就是nano.(nano - Nano's ANOther editor, an enhanced free Pico clone. It's not iPod Nano.前面那句摘自nano命令的手册页,后面那句我加的) 常用参数 nano命令可以打开指定文件进行编辑,默认情况下它会自动断行,即在一行中输入过长的内容时自动拆分

ubuntu 更新引导命令

sudo update-grub 运行结果: Generating grub configuration file ...Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.Found linux image: /boot/vmlinuz-3.13.0-24-genericFound initrd image: /boot/initrd.i

ubuntu的man命令帮助如何设置中文版

原文地址:ubuntu的man命令帮助如何设置中文版 当我们在ubuntu下使用命令,常常需要用到man命令来帮助查看命令参数的意义.但是我们的英文水平不一,因此好多英文解释根本看不懂. [email protected]:~# man vi 比如用该命令查看 vi 的帮助,纯英文很难懂: 其实ubuntu有man的中文包,只需几行命令安装配置即可显示中文帮助.命令如下: apt-get install manpages-zh vi /etc/manpath.config :1,$s#/usr/

ubuntu apt常用命令

apt-cache search packagename 搜索包 apt-cache show packagename 获取包的相关信息,如说明.大小.版本等 apt-get install packagename 安装包 apt-get install packagename --reinstall 重新安装包 apt-get -f install 修复安装 apt-get remove packagename 删除包 apt-get remove packagename --purge 删除

Ubuntu有趣的命令

1 Aptitude $aptitude mooThere are no Easter Eggs in this program.???$ aptitude -v mooThere really are no Easter Eggs in this program.$ aptitude -vv mooDidn't I already tell you that there are no Easter Eggs in this program?$ aptitude -vvv mooOkay, ok

2015.11.06 学习Ubuntu下常用命令

2015.11.06 学习Ubuntu下常用命令 1.关闭防火墙:ufw disable 2.开启防火墙:ufw enable 3.防火墙状态:ufw status 4.查看占用的端口:#lsof -i 5.查看某一个端口:#lsof -i:8080  或者是: #netstat -apn|grep 8080————接着:#ps -aux|grep 进程号 6.结束占用端口的进程:#killall 进程名 7.自己写一遍,记得牢!

ubuntu 解压命令

ubuntu解压命令.tar解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gunzip FileName.gz解压2:gzip -d FileName.gz压缩:gzip FileName.tar.gz 和 .tgz解压:tar zxvf FileName.tar.gz压缩:tar zcvf FileName.tar.gz DirName———————————

Ubuntu下用命令行快速打开各类型文件(转)

nautilus /media/pm/文档/book/system/必读nautilus /media/pm/文档/book/android/ndk 内核/framerwork/android waitReadxdg-open /media/pm/文档/book/system/必读/深入理解linux内核.pdf ubuntu 下一个神奇的命令--以窗口形式打开某个文件夹 今天意外的发现的一个命令 nautilus /media/ 会以窗口的形式打开某个目录,以后写脚本可以用到. Ubuntu下