如何安装最佳开源文本编辑器
文本编辑器可用于编写代码、增强文本文件(例如配置文件)、开发人员指南文档以及更多其他用途。在 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 [email protected] ~ 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 的技巧和提示。继续关注!