“UbuntuHelp:Gedit”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
(未显示同一用户的3个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/gedit}} | {{From|https://help.ubuntu.com/community/gedit}} | ||
{{Languages|UbuntuHelp:gedit}} | {{Languages|UbuntuHelp:gedit}} | ||
− | + | #title Text Editor (gedit) | |
== Introduction == | == Introduction == | ||
− | + | Text Editor (gedit) is the default GUI text editor in the Ubuntu operating system. It is UTF-8 compatible and supports most standard text editor features as well as [http://projects.gnome.org/gedit/ many advanced features]. These include multilanguage spell checking, extensive support of syntax highlighting, and a large number of official and third party plugins. | |
− | + | gedit is suited for both basic and more advanced text editing and is released under the [http://www.gnu.org/licenses/gpl.html GNU General Public License]. | |
− | + | ||
== Screenshot == | == Screenshot == | ||
− | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target= | + | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=gedit.screenshot1.png |
− | == | + | == Installation == |
− | + | gedit is located in Ubuntu's Main repository and is installed by default. gedit can be installed in Kubuntu, Xubuntu and other distributions although additional libraries are necessary and will be installed on non-GNOME systems. | |
− | + | To install gedit: | |
− | * | + | * Select gedit in Synaptic ('''System''' → '''Adminstration''' → '''Synaptic Package Manager''') |
+ | * From a terminal or ALT-F2: | ||
<pre><nowiki> | <pre><nowiki> | ||
− | + | sudo apt-get install gedit | |
</nowiki></pre> | </nowiki></pre> | ||
− | + | == Opening gedit == | |
+ | gedit incorporates a graphical user interface (GUI) and is opened by going to '''Applications''' → '''Accessories''' → '''Text Editor''' or by pressing Alt+F2 and typing '''gedit''' | ||
+ | === Command Line Tips === | ||
+ | Opening gedit via the command line allows the user to take advantage of several options unavailable from the GUI menu. If a path is not included in the startup command, gedit will look for the file in the current directory. If the file is not found, gedit will open a blank file with the file name entered on the command line: | ||
+ | * '''To open a specific file''': | ||
+ | <pre><nowiki> | ||
+ | gedit filename | ||
+ | </nowiki></pre> | ||
+ | * '''To open multiple files''': | ||
+ | <pre><nowiki> | ||
+ | gedit file1 file2 | ||
+ | </nowiki></pre> | ||
+ | * '''To edit system files''' such as sources.list and fstab, open it with administrative privileges. Note graphical applications use ''gksudo'' rather than ''sudo''. | ||
+ | <pre><nowiki> | ||
+ | gksudo gedit | ||
+ | </nowiki></pre> | ||
+ | * '''To open at a specific line number''', useful when an error message includes the line number, include "+<line number>". (''gksudo'' is used in this example since the file is a system file owned by root): | ||
+ | <pre><nowiki> | ||
+ | gksudo gedit +21 /etc/apt/sources.list | ||
+ | </nowiki></pre> | ||
+ | == Configuration Options == | ||
+ | Several popular options which the user may wish to review after the initial installation are: | ||
+ | * Create Backup Copy: '''Edit''' → '''Preferences''' → '''Editor''' tab. This option is enabled by default and creates a copy of the file before saving changes. Backup files saved in this manner are appended with a trailing "~". If the user does not want gedit to back up files in this manner, deselect the option. | ||
+ | * Autosave: '''Edit''' → '''Preferences''' → '''Editor''' tab. This feature is not enabled by default. The user may also select the time between autosaves. | ||
+ | * Spell Checker: '''Edit''' → '''Preferences''' → '''Plugins''' tab. This feature is enabled by default. | ||
+ | == Plugins == | ||
+ | {|border="1" cellspacing="0" | ||
+ | |https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditplugins1.png | ||
+ | |} | ||
+ | Plugins greatly enhance the power of gedit and are are accessed via '''Edit''' → '''Preferences''' → '''Plugins'''. More than a dozen plugins are pre-installed and can be enabled/disabled in this section. Some of the most popular are enabled by default while others must be enabled by the user. | ||
+ | * Tag List. Displays common tags in a side pane and allows for easy insertion into the file. | ||
+ | * External Tools. One of the powerful default plugins available (but not enabled by default), '''External Tools''' allows the user to run external commands on the file being edited from within gedit itself. | ||
+ | * Once this plugin is enabled, the user can select custom tools from the '''Tools''' menu. | ||
+ | * The addition of shortcut keys and the configuration of tools from the '''External Tools Manager''' are accomplished via the '''Tools''' → '''External Tools...''' menu. | ||
+ | For descriptions of standard plugins distributed with the gedit package visit [http://projects.gnome.org/gedit/plugins.html this link]. | ||
+ | Many additional plugins are available from third-party resources. See the Links section near the bottom of this page. | ||
+ | == Syntax Highlighting == | ||
+ | A very useful feature of gedit is the ability to color programming code. Using syntax highlighting makes simple errors easier to recognize. gedit uses the GtkSourceView package for syntax highlighting. The ''.lang'' file for a specific programing language is located in the ''/usr/share/gtksourceview-2.0/language-specs/'' folder. These files may be edited or additional files created to further define the highlighting definitions. | ||
+ | Users of earlier versions of gedit will note that there is no longer a separate '''Syntax Highlight''' tab. Syntax highlighting is now automatic and is selected in one of two methods. It can be chosen via the menu with '''View''', '''Highlight Mode''' or via the lower statusbar. The statusbar, enabled via the '''View''' menu, displays programming language options for many types of sources, scripts, markup and scientific formats. A screenshot of the statusbar in use is located further down this page. | ||
+ | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditsyntax.png | ||
=== Using gedit for XML / Docbook XML === | === Using gedit for XML / Docbook XML === | ||
− | + | gedit provides a user-friendly way to make XML markup or Docbook XML for yelp and ubuntu documentation. The pictures and instructions given below use gedit 2.26.1. The recommended changes help take full advantage of the syntax color highlighting which gedit provides. | |
− | Under the View tab make the following | + | * Under the View tab make the following selections. Selecting most of the options just make life easier. |
− | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target= | + | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditview.png |
− | The | + | * The next change to make is under Editor tab. As one can see there is not much to do here. |
− | + | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=gediteditor.png | |
− | + | * Next is the Plugins Tab. A screenshot of the plugins tab is available in the ''Plugins'' section above. There are a number of changes you can make on the Plugins page, the most important perhaps is the Tag List option. Experiment with other plugins and see what they do. [http://projects.gnome.org/gedit/plugins.html This link] gives a brief explanation of each default plugin. | |
− | As one can see there is not much to do here | + | * Now comes the most interesting part, go to View > Highlight Mode > Markup and while we want Docbook one can also see XML and both look slightly different from each other: |
− | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target= | + | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditdocbook2.png |
− | + | ||
− | + | ||
− | + | ||
− | There are a number of changes you can make | + | |
− | Now comes the most interesting part, go to View > Highlight Mode > Markup and while we want Docbook one can also see XML and both look slightly different from each other: | + | |
− | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target= | + | |
The above one is when the text is highlighted using geditdocbook. The same text when highlighted using XML looks like: | The above one is when the text is highlighted using geditdocbook. The same text when highlighted using XML looks like: | ||
− | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target= | + | https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditmarkup2.png |
− | + | Experiment with gedit's settings and markup in general to have a feel of what works best for you. | |
− | == | + | == Uninstalling gedit == |
− | == | + | If you are running Ubuntu and attempt to remove gedit via Synaptic or apt, the system will also attempt to remove the '''ubuntu-desktop''' metapackage. If you try to remove '''ubuntu-desktop''' specifically in Synaptic the user will be cautioned with: |
− | * [http://www.gnome.org/projects/gedit/ gedit] | + | <pre><nowiki> |
+ | This package depends on all of the packages in the Ubuntu desktop system. | ||
+ | It is also used to help ensure proper upgrades, so it is recommended that it not be removed. | ||
+ | </nowiki></pre> | ||
+ | If the user is experiencing problems with gedit, it may be preferable to first reset the user's preferences by removing the user's .gconf/apps/.gedit2 folder rather than attempting to remove the entire application and the '''ubuntu-desktop''' metapackage. Learn more about Ubuntu's [[UbuntuHelp:MetaPackages|MetaPackages]]. | ||
+ | == Related Apps == | ||
+ | * [http://www.kubuntu.org/docs/kquickguide/C/ch03s06.html Kate] - the installed editor for Kubuntu | ||
+ | * Mousepad - the lightweight text editor for Xubuntu | ||
+ | == External Links == | ||
+ | * [http://www.gnome.org/projects/gedit/ gedit Homepage on gnome.org] | ||
+ | * [http://library.gnome.org/users/gedit/stable/index-info.html.en gedit Manual] | ||
+ | * [http://live.gnome.org/Gedit/Plugins live.gnome.org's Plugins] | ||
---- | ---- | ||
− | [[category: | + | [[category:CategorySoftwareDefault]] [[category:CategorySoftware]] |
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年5月12日 (二) 16:57的最新版本
- title Text Editor (gedit)
目录
Introduction
Text Editor (gedit) is the default GUI text editor in the Ubuntu operating system. It is UTF-8 compatible and supports most standard text editor features as well as many advanced features. These include multilanguage spell checking, extensive support of syntax highlighting, and a large number of official and third party plugins. gedit is suited for both basic and more advanced text editing and is released under the GNU General Public License.
Screenshot
Installation
gedit is located in Ubuntu's Main repository and is installed by default. gedit can be installed in Kubuntu, Xubuntu and other distributions although additional libraries are necessary and will be installed on non-GNOME systems. To install gedit:
- Select gedit in Synaptic (System → Adminstration → Synaptic Package Manager)
- From a terminal or ALT-F2:
sudo apt-get install gedit
Opening gedit
gedit incorporates a graphical user interface (GUI) and is opened by going to Applications → Accessories → Text Editor or by pressing Alt+F2 and typing gedit
Command Line Tips
Opening gedit via the command line allows the user to take advantage of several options unavailable from the GUI menu. If a path is not included in the startup command, gedit will look for the file in the current directory. If the file is not found, gedit will open a blank file with the file name entered on the command line:
- To open a specific file:
gedit filename
- To open multiple files:
gedit file1 file2
- To edit system files such as sources.list and fstab, open it with administrative privileges. Note graphical applications use gksudo rather than sudo.
gksudo gedit
- To open at a specific line number, useful when an error message includes the line number, include "+<line number>". (gksudo is used in this example since the file is a system file owned by root):
gksudo gedit +21 /etc/apt/sources.list
Configuration Options
Several popular options which the user may wish to review after the initial installation are:
- Create Backup Copy: Edit → Preferences → Editor tab. This option is enabled by default and creates a copy of the file before saving changes. Backup files saved in this manner are appended with a trailing "~". If the user does not want gedit to back up files in this manner, deselect the option.
- Autosave: Edit → Preferences → Editor tab. This feature is not enabled by default. The user may also select the time between autosaves.
- Spell Checker: Edit → Preferences → Plugins tab. This feature is enabled by default.
Plugins
![]() |
Plugins greatly enhance the power of gedit and are are accessed via Edit → Preferences → Plugins. More than a dozen plugins are pre-installed and can be enabled/disabled in this section. Some of the most popular are enabled by default while others must be enabled by the user.
- Tag List. Displays common tags in a side pane and allows for easy insertion into the file.
- External Tools. One of the powerful default plugins available (but not enabled by default), External Tools allows the user to run external commands on the file being edited from within gedit itself.
- Once this plugin is enabled, the user can select custom tools from the Tools menu.
- The addition of shortcut keys and the configuration of tools from the External Tools Manager are accomplished via the Tools → External Tools... menu.
For descriptions of standard plugins distributed with the gedit package visit this link. Many additional plugins are available from third-party resources. See the Links section near the bottom of this page.
Syntax Highlighting
A very useful feature of gedit is the ability to color programming code. Using syntax highlighting makes simple errors easier to recognize. gedit uses the GtkSourceView package for syntax highlighting. The .lang file for a specific programing language is located in the /usr/share/gtksourceview-2.0/language-specs/ folder. These files may be edited or additional files created to further define the highlighting definitions.
Users of earlier versions of gedit will note that there is no longer a separate Syntax Highlight tab. Syntax highlighting is now automatic and is selected in one of two methods. It can be chosen via the menu with View, Highlight Mode or via the lower statusbar. The statusbar, enabled via the View menu, displays programming language options for many types of sources, scripts, markup and scientific formats. A screenshot of the statusbar in use is located further down this page.
Using gedit for XML / Docbook XML
gedit provides a user-friendly way to make XML markup or Docbook XML for yelp and ubuntu documentation. The pictures and instructions given below use gedit 2.26.1. The recommended changes help take full advantage of the syntax color highlighting which gedit provides.
- Under the View tab make the following selections. Selecting most of the options just make life easier.
- The next change to make is under Editor tab. As one can see there is not much to do here.
- Next is the Plugins Tab. A screenshot of the plugins tab is available in the Plugins section above. There are a number of changes you can make on the Plugins page, the most important perhaps is the Tag List option. Experiment with other plugins and see what they do. This link gives a brief explanation of each default plugin.
- Now comes the most interesting part, go to View > Highlight Mode > Markup and while we want Docbook one can also see XML and both look slightly different from each other:
The above one is when the text is highlighted using geditdocbook. The same text when highlighted using XML looks like:
Experiment with gedit's settings and markup in general to have a feel of what works best for you.
Uninstalling gedit
If you are running Ubuntu and attempt to remove gedit via Synaptic or apt, the system will also attempt to remove the ubuntu-desktop metapackage. If you try to remove ubuntu-desktop specifically in Synaptic the user will be cautioned with:
This package depends on all of the packages in the Ubuntu desktop system. It is also used to help ensure proper upgrades, so it is recommended that it not be removed.
If the user is experiencing problems with gedit, it may be preferable to first reset the user's preferences by removing the user's .gconf/apps/.gedit2 folder rather than attempting to remove the entire application and the ubuntu-desktop metapackage. Learn more about Ubuntu's MetaPackages.
Related Apps
- Kate - the installed editor for Kubuntu
- Mousepad - the lightweight text editor for Xubuntu