歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux nano文本編輯器

Linux nano文本編輯器

日期:2017/2/28 16:23:06   编辑:Linux教程

GNU nano 1.2.4,nano的版本 File: /etc/network/interfaces打開的文件的絕對地址

下面就是打開的文件的內容
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.254.20
netmask 255.255.255.0
network 192.168.254.0
broadcast 192.168.254.255
gateway 192.168.254.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.103.0.117 202.103.24.68
[ Read 17 lines ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Txt ^T To Spell

這些是幫助欄目,呵呵^G表示ctrl+g一起按,呵呵

^G Get Help表示同時按ctrl和G,就是調出幫助菜單

我們來試一下
我按了一下就調出了幫助菜單了,我下面就直接把快捷鍵表給大家,大家試試吧

一直以來vi都被人們說是最強大的編輯器,但gentoo和debian選擇nano做了默認的編輯器
freebsd選擇ee做了默認的編輯器,我相信在專業人士眼睛裡面freebsd和redaht比較起來,
RedHat基本沒什麼可以炫耀的,為什麼他們不選擇vi呢,因為vi操作比較復雜
而所謂的簡單編輯器nano就簡單,非常容易上手,說是簡單編輯器
其實一點都不簡單,只不過是nano謙虛一下罷了

這裡聲明一下^表示鍵盤上的ctrl鍵,上個只要是做過編程的朋友應該都清楚,^G表示同時按下ctrl和g
(F1)表示按(F1)也是一樣的 ,M-表示使用alt+後面的鍵

^G ==F1) Invoke the help menu
調用幫助菜單

^X ==(F2) Close currently loaded file/Exit from nano
退出

^O ==(F3) Write the current file to disk == ^O WriteOut
保存
然後回車就保存了

^J ==(F4) Justify the current paragraph
調整當前段落(配置文件的不要用這東西,格式一下就出問題了哦)

^R ==(F5) Insert another file into the current one
插入其他的文件到當前的文件,而且查找文件的時候支持tab

^W ==(F6) Search for text within the editor

查找
^Y ==(F7) Move to the previous screen
上一屏幕
^V ==(F8) Move to the 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) Show the position of the cursor
顯示光標位置

^T ==(F12) Invoke the spell checker, if available

調用拼寫檢查程序

^P Move up one line

向上移動一行
^N Move down one line

向下移動一

^F Move forward one character
向前移動光標一格

^B Move back one character
向後移動光標一格

^A Move to the beginning of the current line
移動到當前行的開頭

^E Move to the end of the current line
移動到當前行的末尾

^L Refresh (redraw) the current screen
刷新當前屏幕

^^ (M-A) Mark text at the current cursor location
標記文本

^D Delete the character under the cursor

刪除光標後一個字母
^H Delete the character to the left of the cursor
向左邊刪一個字母
^I Insert a tab character
插入一個tab值
^\ (F14) (M-R) Replace text within the editor

查找並且替換
^M Insert a carriage return at the cursor position
插入一個回車
^_ (F13) (M-G) Go to a specific line number

跳轉到某行
^Space Move forward one word

前進一個單詞
M-Space Move backward one word
後退一個單詞
M-] Find other bracket
搜索下一個括號

M-< Open previously loaded file
打開先前加載的文件

M-> Open next loaded file

打開下一個加載的文件

M-C Constant cursor position enable/disable


M-I Auto indent enable/disable
是否首行縮進

M-Z Suspend enable/disable
是否懸掛

M-X Help mode enable/disable
幫助模式

M-M Mouse support enable/disable

鼠標支持

M-Y Color syntax highlighting enable/disable
語法加亮


這個就是退出了哦


好了nano 的編輯器就說這樣多了
然後我們來說一下基本的幾個配置文件以及地方
首先是打開命令行高效輸入的位置
看到了高級的命令行補全,連軟件包的名字都不需要記了哦,呵呵,是不是很爽哦

怎麼ls沒顏色了,你們是不是在redhat裡面看到過顏色啊,那我們來改
看到了沒,蘭色是目錄,白色是文件,綠色是可以運行的文件

cnrot:/# ll
-bash: ll: command not found
告訴我們ll沒這個命令
那我們來做一個自己定義的命令吧
記住要注銷才生效,不需要重新啟動的哦
看到了沒
看到了沒,這是自己定義命令哦
好了,我現在 給大家說幾個文件的位置吧

怕大家找不到
首先是網絡配置文件/etc/network/interfaces

GNU nano 1.2.4 File: /etc/network/interfaces Modified

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.254.20
netmask 255.255.255.0
network 192.168.254.0
broadcast 192.168.254.255
gateway 192.168.254.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.103.0.117 202.103.24.68

安裝源配置文件
GNU nano 1.2.4 File: /etc/apt/sources.list

#deb file:///cdrom/ sarge main

deb cdrom:[Debian GNU/Linux 3.1 r0a _Sarge_ - Official i386 Binary-1 (20050607)$

deb http://debian.cn99.com/debian/ stable main
deb-src http://debian.cn99.com/debian/ stable main

deb http://security.debian.org/ stable/updates main contrib

拷貝、剪切以及粘貼:
可以按住鼠標左鍵之後拉動鼠標將您需要復制的文本反白顯示,然後將光標移動到想插入內容的地方,直接點鼠標右鍵,即可把剛才用鼠標選擇的反白文本粘貼到該處。
也可以先把在windows下的文本編輯器或者浏覽器上的某些文本復制下來,然後切換到nano中,將光標移到想插入內容的地方,直接點鼠標右鍵,就可以將剛才復制在內存中的文本粘貼到該處。
還可以將光標移動到需要復制(或者剪切)的文本的初始位置,然後按Ctrl+6(或者Alt+A)做下標記,再移動光標到需要復制、剪切的文本結束位置。將選定的文本反白顯示,最後將光標移動到想插入內容的地方,按Alt+6來將剛才選擇的內容復制到該位置(或者按Ctrl+K來剪切)。如果在選擇文本的過程中想要取消掉剛才的選擇,那麼要再按一次Ctrl+6即可取消剛才的選擇。
另外可以使用Alt+6來復制一整行的內容到內存,然後將光標移動到您想插入內容的地方,直接點鼠標右鍵即可完成粘貼。
將Alt+6換成Ctrl+K,即可剪切。
或者您也可用Ctrl+U來代替鼠標右鍵來完成粘貼。
搜索:
按下Ctrl+W,然後鍵入你要搜索的字符串,再按回車Enter就可以了。
如果想再次搜索相同的字符串,可以直接按Alt+W即可。
翻頁:
Ctrl+Y上翻頁、Ctrl+V下翻頁。
保存與退出:
如要保存修改,按Ctrl+O。
退出,按Ctrl+X。這時如果在退出前沒有保存所做的修改,將會提示你是否要保存。如果需要保存請按Y並回車Enter,不需要保存則按N然後回車Enter。
當文件為新建文件時,選擇保存將會讓你確認要保存的文件名。
幫助:
按Ctrl+G可以查看nano的幫助文檔。
在nano幫助文檔裡,Ctrl鍵表示為^,Ctrl+W顯示為^W。Alt鍵被表示為一個M,因此Alt+W顯示為M-W。
如果想調整nano設置,可以編輯/etc/nanorc
另外如果您的Linux版本裡未自帶nano的話,請用如下命令安裝nano即可:
rpm -Uvh nano-x.y.z-1.i386.rpm
RedHat:dpkg -i nano_x.y.z-1.deb
CentOS:yum -y install nano
Debian:apt-get install -y nano
也可以自己下載自己編譯:
tar -zxvf nano-x.y.z.tar.gz
如果出現- z的錯誤信息
gzip -dc nano-x.y.z.tar.gz | tar xvf -
如果需要運行配置選項:
cd nano-x.y.z/
./configure
make
make install

Copyright © Linux教程網 All Rights Reserved