gedit
GNOME's simple graphical text editor
By CMD Script Team · 4 min read · Last updated
gedit [OPTIONS] [FILE...]Options
| Flag | Description |
|---|---|
+LINE | Open the file with the cursor positioned on the given line number |
--new-window | Open the file in a new gedit window instead of a new tab in an existing one |
--new-document | Create a new, empty document |
-b, --standalone | Run gedit as a standalone application, ignoring any already-running instance |
--wait | Block until the opened file is closed, useful when gedit is set as $EDITOR |
Distribution compatibility
- Ubuntu
- Debian
- Fedora
What it does
gedit is GNOME's default graphical text editor: a windowed application with menus,
tabs, mouse-driven selection, and no modal editing states, making it approachable for
users who don't want to learn terminal editors like vi. It supports syntax
highlighting for common programming and markup languages, basic find-and-replace, and a
plugin system, while remaining deliberately simpler than a full IDE.
Beginner examples
gedit file.txt— open a file in a gedit windowgedit— open gedit with a blank new documentgedit file1.txt file2.txt— open two files as separate tabs in one window- Use the mouse or arrow keys to move around and just start typing — no mode switching required
gedit ~/notes/todo.txt
Advanced examples
- Jump straight to a specific line when opening a file:
gedit +120 app.py - Force a brand-new window rather than a tab in an existing instance:
gedit --new-window config.yaml - Open gedit and block the calling shell until it's closed, useful for setting it as
$EDITORfor tools likegit commit:EDITOR="gedit --wait" git commit - Open several related files at once as tabs for quick comparison:
gedit main.py utils.py tests.py - Launch a completely independent instance ignoring any already-open gedit window:
gedit --standalone file.txt
EDITOR="gedit --wait" git commit
Common mistakes
- Expecting
geditto work in a headless server session over plain SSH — it requires a graphical environment (X11 forwarding or a local desktop), so it will fail or hang on a server with no display. - Assuming
geditis available on macOS by default — it's a GNOME/GTK application and isn't part of a standard macOS installation. - Setting
EDITOR=geditfor command-line tools without--wait, causing the calling program (likegit commit) to think the edit finished immediately since gedit doesn't block by default. - Confusing gedit's simple find/replace with the more powerful regex-based
search-and-replace of tools like
sedor a full IDE.
Tips
- Combine
+LINEwith a build tool or linter's error output to jump straight to the problem line:gedit +$(grep -n "error" output.log | cut -d: -f1) file.py. - Use
gedit --waitwhen configuring it as a Git or other CLI tool's default editor, so the calling process correctly waits for you to finish and close the file. - For quick edits on a remote headless server, prefer a terminal editor like
viornano— savegeditfor local desktop sessions.
Best practices
- Reserve
geditfor local, interactive desktop editing rather than remote server administration, where a terminal editor is more practical and often the only option. - When scripting an editor invocation from the command line (e.g. via
$EDITOR), always pairgeditwith--waitso calling tools behave correctly. - For anything beyond quick edits — real development work with debugging, refactoring, and project-wide search — reach for a full IDE or code editor rather than gedit, which is intentionally minimal.
Try it yourself
A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.
Real-world use cases
- Quickly editing a configuration file or script on a GNOME desktop without needing terminal editor skills.
- Making gedit the
$EDITORfor Git commit messages on a developer's local Linux desktop. - Opening and comparing a few small related files side by side as tabs during casual editing.
Common interview questions
- What kind of application is gedit, and how does that differ from vi? gedit is a
graphical, non-modal text editor with a GUI (menus, mouse, tabs);
viis a terminal- based modal editor with no GUI, making it usable over SSH and on headless systems where gedit cannot run. - Why might gedit not be a good choice for remote server administration? It requires a graphical display; on a headless server accessed only via SSH, there's no way to run it without X11 forwarding, which is often unavailable or impractical.
- How would you configure gedit as your Git commit editor correctly? Set
EDITOR="gedit --wait"so Git waits for the gedit window to close before continuing, since gedit doesn't block the terminal by default.
Frequently Asked Questions
Is gedit available on macOS?
No. gedit is a GNOME desktop application built on GTK, and while an unofficial macOS port has existed at times, it is not a standard part of macOS and isn't installed or maintained there the way it is on GNOME-based Linux distributions.
How is gedit different from vi or nano?
gedit is a graphical application with a window, menus, mouse support, and no modal editing — you just click and type, like a typical desktop text editor. vi and nano are terminal-based editors that work over SSH and on systems with no graphical environment.
Can I open a file at a specific line number from the terminal?
Yes, use gedit +42 file.txt to open the file with the cursor already positioned on line 42.
Does gedit support syntax highlighting and plugins?
Yes, gedit recognizes many programming and markup languages for syntax highlighting out of the box and supports a plugin system for features like a terminal panel, spell-check, and file browsing.
Cheat sheet
Download a quick-reference cheat sheet for gedit.