首页 > 代码库 > ·Ubuntu」Nano命令
·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 availableM-\ (M-|) Go to the first line of the fileM-/ (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 positionM-W (F16) Repeat last searchM-^ (M-6) Copy the current line and store it in the cutbufferM-} Indent the current lineM-{ Unindent the current line^F Go forward one character^B Go back one character^Space Go forward one wordM-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 lineM-( (M-9) Go to beginning of paragraph; then of previous paragraphM-) (M-0) Go just beyond end of paragraph; then of next paragraphM-] Go to the matching bracketM-- (M-_) Scroll up one line without scrolling the cursorM-+ (M-=) Scroll down one line without scrolling the cursorM-< (M-,) Switch to the previous file bufferM-> (M-.) Switch to the next file bufferM-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 cursorM-T Cut from the cursor position to the end of the fileM-J Justify the entire fileM-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
·Ubuntu」Nano命令
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。