How to Edit Text Files Using the gEdit Linux Text Editor

Learn how to navigate the interface and work with files

gEdit is a Linux text editor commonly deployed as part of the GNOME desktop environment. While most Linux guides and tutorials recommend using the nano editor or vi to edit text files and configuration files, the gEdit editor is easier to use than nano and vi and works the same as Microsoft Windows Notepad.

How to Start gEdit

On a distribution with the GNOME desktop environment, press the Super key (the key with the Windows logo on it, next to the ALT key). Then, type Edit into the search bar and select the Text Editor icon.

Text Editor

To open files in gEdit:

  1. Open the Nautilus file manager.

  2. Navigate to the folder that contains the file you want to open.

  3. Right-click the file.

  4. Select Open with text editor. If you don't see this option, select Open with other application, then choose the Text editor option.

You can also edit files in gEdit from the command line. Open a terminal and type the following command:


To open a specific file, specify the filename after the gedit command, as follows:

gedit /path/to/file
Linux Gedit open from CLI

Run the gedit command as a background command so that the cursor returns to the terminal after you execute the command to open it. To run a program in the background, add the ampersand symbol, as follows:

gedit &

The gEdit User Interface

The gEdit user interface contains a single toolbar at the top with a panel for entering the text below it.

The toolbar contains items to open and save files, add tabs, and control the window. Select Open to display a window with a search bar to search for documents, a list of recently accessed documents, and the option to access Other Documents. When you choose Other Documents, a file dialog appears where you can search the directory structure for the file you want to open.

Other Documents button in gEdit

There is a plus symbol (+) next to Open. When you select it, a new tab is added so that you can edit multiple documents at the same time.

Plus tab in Text Editor

Save displays the File dialog. Choose a location in the file system to save the file. You can also choose the character encoding and the file type.

The Options icon is denoted by three vertical lines. When selected, it opens a new menu with options to refresh the screen, save and print a document, find information in a document, change the view, and more.

The other three icons minimize, maximize, and close the editor.

Linux gedit options

Refresh the Document

Refresh can be found on the Options menu. This option is enabled when the document you are editing has changed since you first opened it.

If a file changes after you have loaded it, a message appears on the screen asking you whether you wish to reload it.

Print a Document

The Print icon on the Options menu displays the Print Settings screen, and you can choose to print the document to a file or printer.

Display a Document Full Screen

The Full Screen icon on the Options menu displays the gEdit window as a full-screen window and hides the toolbar. To turn off full-screen mode, hover the mouse pointer over the top of the window and click the Full Screen icon again.

Save a Document

The Save as menu item on the Options menu shows the File Save dialog box. Use it to choose where to save the file. The Save All menu item saves all the files open on all the tabs.

Search for Text

The Find menu item can be found on the Options menu. Select the Find menu item to display a search bar. You can enter the text to search for and choose the direction to search (up or down the page).

Linux gedit find

The Find and replace menu item opens a window where you can search for text and enter the text you wish to replace it with. You can also match by case, search backward, match the entire word only, wrap around, and use regular expressions. The options on this screen let you find, replace, or replace all matched entries.

Clear Highlighted Text

The Clear Highlight menu item is found on the Options menu. This clears selected text that was highlighted using the Find option.

Go to a Specific Line

To go to a specific line, select the Go To Line menu item on the Options menu. A small window opens where you can enter the line number you want to go to.

Linux gedit go to line

If the line number you enter is longer than the file, the cursor moves to the bottom of the document.

Display a Side Panel

Go to the Options and select the View sub-menu to find the option to display or hide the side panel. The side panel shows a list of open documents. To view a document, click it.

Highlight Text

The available highlighting options depend on the type of document. To highlight text, go to the Options menu, select View, then choose Highlight Mode. The list of modes includes options for programming languages, including Perl, Python, Java, C, VBScript, Actionscript, and more.

The text is highlighted using the keywords for the language chosen. For example, if you chose SQL as the highlight mode, the script might look like this:

select * from tablename where x = 1

Set the Language

To set the language of the document, open the Options menu. Then, from the Tools sub-menu, choose Set Language. You can choose from several languages.

Check the Spelling

To spell-check a document, open the Options menu, select the Tools menu, then choose Check Spelling.

When a word is misspelled, a list of suggestions displays. You can choose to ignore, ignore all, change, or change all occurrences of the incorrect word.

There is another option on the Tools menu called Highlight misspelled words. When checked, any incorrectly spelled words are highlighted.

Insert the Date and Time

To insert the date and time into a document, go to the Options menu, select the Tools menu, then choose Insert date and time. A window appears from which you can choose the format for the date and time.

Linux gedit date and time

Get Statistics for Your Document

Under Options > Tools, there is an option called Statistics. This shows a new window with statistics for the number of lines, words, characters (with spaces), characters (without spaces), and bytes.


To find the preferences, select the Options > Preferences. A window appears with four tabs appears: View, Editor, Fonts and Colors, and Plugins.

  • Go to the View tab to choose whether to display line numbers, a right margin, a status bar, an overview map, or a grid pattern. You can also turn word wrap on and off, split a single word over multiple lines, and control how highlighting works.
  • Go to the Editor tab to set the spacing for tabs, insert spaces instead of tabs, and choose how often a file is auto-saved.
  • Go to the Fonts and Colors tab to choose the theme used by gEdit as well as the default font family and size.
  • Go to the Plugins tab to find the plugins available for gEdit. Some plugins are highlighted. To enable others, place a check in the box. 
Plugins tab in Preferences
Was this page helpful?