如何安裝最佳開源文字編輯器
文字編輯器可用於編寫程式碼、增強文字檔案(例如配置檔案)、開發人員指南文件以及更多其他用途。在 Linux 中,文字編輯器分為兩種型別,即圖形使用者介面 (GUI) 和命令列文字編輯器。本文介紹瞭如何安裝最佳開源文字編輯器。
Vi/Vim 編輯器
Vim 既可用於命令列介面,也可作為圖形使用者介面中的獨立應用程式使用。Vim 是免費的開源軟體,並根據包含一些慈善軟體條款的許可證釋出。要安裝 vim 編輯器,請使用以下命令:
$ sudo apt-get install vim
示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apport-hooks-elementary contractor javascript-common libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1 libindicate5 libjs-jquery libnoise-core0 libtagc0 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: vim-runtime Suggested packages: ctags vim-doc vim-scripts vim-gnome-py2 | vim-gtk-py2 | vim-gtk3-py2 | vim-athena-py2 | vim-nox-py2 The following NEW packages will be installed: vim vim-runtime 0 upgraded, 2 newly installed, 0 to remove and 36 not upgraded. Need to get 6,184 kB of archives. After this operation, 29.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1 [5,175 kB] ..................................................................................................
要開啟 vim 文字編輯器,請使用以下命令:
$ vim
示例輸出應如下所示:
~ ~ ~ ~ ~ VIM - Vi IMproved ~ ~ version 7.4.1689 ~ by Bram Moolenaar et al. ~ Modified by pkg-vim-maintainers@lists.alioth.debian.org ~ Vim is open source and freely distributable ~ ~ Become a registered Vim user! ~ type :help register for information ~ ~ type :q to exit ~ type :help or for on-line help ~ type :help version7 for version info ~ ~ ~ ~ ~ 0,0-1 All
要獲取有關 vim 文字編輯器的更多資訊,請使用以下命令:
$ vim -h
示例輸出應如下所示:
IM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 08 2016 11:38:28) usage: vim [arguments] [file ..] edit specified file(s) or: vim [arguments] - read text from stdin or: vim [arguments] -t tag edit file where tag is defined or: vim [arguments] -q [errorfile] edit file with first error Arguments: -- Only file names after this -v Vi mode (like "vi") -e Ex mode (like "ex") -E Improved Ex mode -s Silent (batch) mode (only for "ex") -d Diff mode (like "vimdiff") -y Easy mode (like "evim", modeless) -R Readonly mode (like "view") -Z Restricted mode (like "rvim") -m Modifications (writing files) not allowed -M Modifications in text not allowed -b Binary mode -l Lisp mode -C Compatible with Vi: 'compatible' -N Not fully Vi compatible: 'nocompatible' -V[N][fname] Be verbose [level N] [log messages to fname] -D Debugging mode -n No swap file, use memory only -r List swap files and exit -r (with file name) Recover crashed session -L Same as -r -A start in Arabic mode -H Start in Hebrew mode -F Start in Farsi mode -T Set terminal type to --not-a-term Skip warning for input/output not being a terminal -u Use instead of any .vimrc --noplugin Don't load plugin scripts -p[N ]Open N tab pages (default: one for each file) -o[N] Open N windows (default: one for each file) -O[N] Like -o but split vertically + Start at end of file + Start at line --cmd Execute before loading any vimrc file -c Execute after loading the first file -S Source file after loading the first file -s Read Normal mode commands from file -w Append all typed commands to file -W Write all typed commands to file -x Edit encrypted files --startuptime Write startup timing messages to -i Use instead of .viminfo -h or --helpPrint Help (this message) and exit --versionPrint version information and exit
Gedit
gedit 是 GNOME 桌面環境的預設文字編輯器,也是 GNOME 核心應用程式的一部分。gedit 旨在成為一個通用文字編輯器,根據 GNOME 專案的理念,它強調簡單易用,並具有簡潔直觀的 GUI。它包括用於編輯原始碼和結構化文字(例如標記語言)的工具。要安裝 Gedit 編輯器,需要支援的儲存庫,如下所示:
$ sudo add-apt-repository ppa:ricotz/staging $ sudo add-apt-repository ppa:gnome3-team/gnome3 $ sudo add-apt-repository ppa:gnome3-team/gnome3-staging $ sudo add-apt-repository ppa:ricotz/testing
現在,使用更新命令更新本地儲存庫索引,如下所示:
$ sudo apt-get update
要安裝 Gedit,請使用以下命令:
$ sudo apt-get install gedit
示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apport-hooks-elementary contractor javascript-common libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1 libindicate5 libjs-jquery libnoise-core0 libtagc0 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: gedit-common libgail-3-0 libgspell-1-1 libgtk-3-0 libgtk-3-common libgtksourceview-3.0-1 libgtksourceview-3.0-common libwayland-client0 libwayland-cursor0 Suggested packages: gedit-plugins The following NEW packages will be installed: libgspell-1-1 The following packages will be upgraded: gedit gedit-common libgail-3-0 libgtk-3-0 libgtk-3-common libgtksourceview-3.0-1 libgtksourceview-3.0-common libwayland-client0 libwayland-cursor0 9 upgraded, 1 newly installed, 0 to remove and 132 not upgraded. Need to get 8,882 kB of archives. .................................................................
要開啟 gedit 編輯器,請使用以下命令:
$ sudo gedit
要獲取有關 gedit 的更多資訊,請使用以下命令:
$ gedit -h
示例輸出應如下所示:
Usage: gedit [OPTION...] [FILE...] [+LINE[:COLUMN]] Help Options: -h, --help Show help options --help-all Show all help options --help-gapplication Show GApplication options --help-gtk Show GTK+ Options Application Options: -V, --version Show the application's version --list-encodings Display list of possible values for the encoding option --encoding=ENCODING Set the character encoding to be used to open the files listed on the command line --new-window Create a new top-level window in an existing instance of gedit --new-document Create a new document in an existing instance of gedit -g, --geometry=GEOMETRY Set the size and position of the window (WIDTHxHEIGHT+X+Y) -w, --wait Open files and block process until files are closed -s, --standalone Run gedit in standalone mode --display=DISPLAY X display to use
Geany 編輯器
Geany 是一個輕量級的 GUI 文字編輯器,使用 Scintilla 和 GTK+,幷包含一些基本的 IDE 功能。它旨在具有較短的載入時間,並且對 Linux 上的單獨包或外部庫的依賴性有限。它已移植到各種作業系統,例如 BSD、Linux、Mac OS X、Solaris 和 Windows。支援的程式語言和標記語言包括 C、C++、C#、Java、JavaScript、PHP、HTML、LaTeX、CSS、Python、Perl、Ruby、Pascal、Haskell、Erlang、Vala 等。
要安裝 Geany 編輯器,請使用以下命令:
$ sudo apt-get install geany geany-common
示例輸出應如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apport-hooks-elementary contractor javascript-common libgda-5.0-4 libgda-5.0-common libgranite-common libgranite3 libgsignon-glib1 libindicate5 libjs-jquery libnoise-core0 libtagc0 Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: geany geany-common 0 upgraded, 2 newly installed, 0 to remove and 132 not upgraded. Need to get 2,772 kB of archives. After this operation, 10.8 MB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 geany-common all 1.27-1 [1,795 kB] Get:2 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 geany amd64 1.27-1 [977 kB] Fetched 2,772 kB in 2s (1,018 kB/s) Selecting previously unselected package geany-common. (Reading database ... 183072 files and directories currently installed.) Preparing to unpack .../geany-common_1.27-1_all.deb ... Unpacking geany-common (1.27-1) ... Selecting previously unselected package geany. Preparing to unpack .../geany_1.27-1_amd64.deb ... Unpacking geany (1.27-1) ... Processing triggers for doc-base (0.10.7) ... .............................................................................
要開啟 Geany 編輯器,請使用以下命令:
$ geany
示例輸出應如下所示:
要獲取有關 geany 的更多資訊,請使用以下命令:
$ geany -h
示例輸出應如下所示:
Usage: geany [OPTION...] [FILES...] Help Options: -h, --help Show help options --help-all Show all help options --help-gtk Show GTK+ Options Application Options: --column Set initial column number for the first opened file (useful in conjunction with --line) -c, --config Use an alternate configuration directory --ft-names Print internal filetype names -g, --generate-tags Generate global tags file (see documentation) -P, --no-preprocessing Don't preprocess C/C++ files when generating tags file -i, --new-instance Don't open files in a running instance, force opening a new instance --socket-file Use this socket filename for communication with a running Geany instance --list-documents Return a list of open documents in a running Geany instance -l, --line Set initial line number for the first opened file -m, --no-msgwin Don't show message window at startup -n, --no-ctags Don't load auto completion data (see documentation) -p, --no-plugins Don't load plugins --print-prefix Print Geany's installation prefix -r, --read-only Open all FILES in read-only mode (see documentation) -s, --no-session Don't load the previous session's files -t, --no-terminal Don't load terminal support --vte-lib Filename of libvte.so -v, --verbose Be verbose -V, --version Show version and exit --display=DISPLAY X display to use
閱讀完本文後,您將能夠理解“如何安裝最佳開源文字編輯器”。在我們的下一篇文章中,我們將推出更多基於 Linux 的技巧和提示。繼續關注!