个人工具

“UbuntuHelp:Gedit”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
第2行: 第2行:
 
{{Languages|UbuntuHelp:gedit}}
 
{{Languages|UbuntuHelp:gedit}}
 
#title Text Editor (gedit)
 
#title Text Editor (gedit)
<<Include(Tag/ContentCleanup)>>
 
 
== Introduction ==
 
== Introduction ==
Text Editor (gedit) is the default text editor in Ubuntu, suited for both basic and more advanced text editing. It is pre-installed on most releases of Ubuntu.
+
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=scrn-gedit.png
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=gedit.screenshot1.png
== Hints and Tips ==
+
== Installation ==
* To enable or disable automatic saving of backup files: Preferences > Editor > File Saving
+
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 make display text larger or smaller: Preferences > Fonts & Colors
+
To install gedit:
* For editing configuration files, for example your repository list (in Terminal):
+
* Select gedit in Synaptic ('''System''' → '''Adminstration''' → '''Synaptic Package Manager''')
 +
* From a terminal or ALT-F2:
 
<pre><nowiki>
 
<pre><nowiki>
gksudo gedit /etc/apt/sources.list
+
sudo apt-get install gedit
 
</nowiki></pre>
 
</nowiki></pre>
Note: If you need to run graphical applications as root, use gksudo, as shown above, as it will set up the environment more appropriately. Avoid ever using sudo with gui apps.
+
== 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 ===
One can use gedit for a more user-friendly way to make XML markup or Docbook XML for yelp documentation. The pictures and instructions given below uses gedit 2.18.1. You should make a few changes in gedit to take full benefit of the syntax color highlighting which gedit provides so simple mistakes are caught early. The process for this is as follows:
+
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 changes:
+
* 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=gedit1.png
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditview.png
The only one which could be an option is whether or not to see line numbers, but apart from that, 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.  
Now the next change to make is under Editor tab:
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=gediteditor.png
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=gedit2.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 the next thing is to go to the Syntax Highlighting tab.
+
* 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=geditsyntaxhighlight.png
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditdocbook2.png
Now make sure that Syntax highlighting is turned on. Just to understand or for kicks go down the drop-down menu and see Docbook, on the left-hand side you see the various Elements and can see the various colors associated with that element. Later on you can change the preferences to your liking as you become more aware of what you would like to see or are more comfortable with.
+
Now jump to the Plugins Tab:
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditplugins.png
+
There are a number of changes you can make here, the most important perhaps is the Tag List option. Feel free to make use of other options and see how that changes the text.
+
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=geditdocbook.png
+
 
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=geditmarkup.png
+
https://help.ubuntu.com/community/gedit?action=AttachFile&do=get&target=geditmarkup2.png
That's all, feel free to play around with gedit and markup in general to have a feel of what works and what doesn't.
+
Experiment with gedit's settings and markup in general to have a feel of what works best for you.
#== Other applications you may wish to look at ==
+
== 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:
 +
<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 ==
 
== External Links ==
* [http://www.gnome.org/projects/gedit/ Gedit's Homepage on gnome.org]
+
* [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:CategorySoftwareDefault]] [[category:CategorySoftware]] [[category:CategoryCleanup]]
+
[[category:CategorySoftwareDefault]] [[category:CategorySoftware]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年5月12日 (二) 16:57的最新版本


  1. 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

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 (SystemAdminstrationSynaptic 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 ApplicationsAccessoriesText 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: EditPreferencesEditor 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: EditPreferencesEditor tab. This feature is not enabled by default. The user may also select the time between autosaves.
  • Spell Checker: EditPreferencesPlugins tab. This feature is enabled by default.

Plugins

gedit?action=AttachFile&do=get&target=geditplugins1.png

Plugins greatly enhance the power of gedit and are are accessed via EditPreferencesPlugins. 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 ToolsExternal 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. gedit?action=AttachFile&do=get&target=geditsyntax.png

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.

gedit?action=AttachFile&do=get&target=geditview.png

  • The next change to make is under Editor tab. As one can see there is not much to do here.

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. 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:

gedit?action=AttachFile&do=get&target=geditdocbook2.png The above one is when the text is highlighted using geditdocbook. The same text when highlighted using XML looks like: 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:

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

External Links