Customizing gedit as a Web Developer's IDE
As a web developer and programmer, I prefer to use a powerful text editor over WYSIWYG software. I write code using HTML/XHTML, CSS, Javascript, PHP, MySQL, Ruby, etc. The standard text editor that comes with GNOME is much more powerful than you may know. This article is written to illustrate how you can configure gedit for use as a powerful, stable web developer's text editor.
Features
By using the plug-ins and settings as I discuss in this post, gedit has the following features as a web developer's text editor.- VERY STABLE! You won't lose your work due to a crash!
- Syntax highlighting for PHP, HTML, CSS, Javascript, and just about any other language you'll use as a web developer.
- Line numbers.
- Right margin guide.
- Auto Indentation
- Indent/Unindent selected block of code
- Spaces or tabs with cusomizable tab width and optional modeline support.
- Matching bracket highlighting.
- Side pane file browser with FTP, SFTP, SSH, etc. support.
- Side pane tag list with XHTML Elements, XHTML Attributes, CSS Properties, and PHP Functions.
- Snippet library with accelerators and "Tab Triggers".
- Validate HTML using Tidy.
- Beautify/Cleanup HTML using Tidy.
- Parse and check syntax of PHP using php.
- Beautify PHP using PHP_Beautifier.
- Reference the function under the cursor in the online PHP manual.
- Customizable external tools--the sky is the limit.
- Color picker to insert hex color from a standard GTK+ color wheel.
Preferences
At first glance, gedit just looks like your typical text editor. However, a few clicks in the preferences dialog and it starts to look like a programmer's editor. For the most part, the settings are all pretty common amongst editors, especially GtkSourceView based editors such as gedit. GtkSourceView is the text editing component which handles the base features such as syntax highlighting.
Personally, I like to have the following preferences set:
- View
-
- Uncheck "Enable text wrapping"
- Check "Display line numbers"
- Check "Highlight current line"
- Check "Display right margin" and set to 80. (I manually wrap my code at 80 characters)
- Highlight matching bracket (when cursor is at a bracket, it's pair is highlighted as shown in the image above).
- Editor
-
- Check "Use spaces instead of tabs" and set "Tab width" to 4. (We can use modelines to change this from file to file)
- Check "Enable auto indentation"
- Uncheck "Create a backup copy of file before saving". (I manually backup everything before I start work)
- Font & Color
-
- Uncheck "Use default theme font" and set "Editor Font" to "Monospace 10".
- Syntax Highlighting
-
- GtkSourceView has default colors it'll use for syntax
highlighting. However, you can customize it here for gedit.
Personally, I like to modify the PHP highlighting to look
similiar to the PHP highlighting as PHP would output it (as
seen in the PHP manual and on zend.com). If you would like to
use my PHP color scheme, download
gedit_php_highlight.xml and execute this command (note:
you will need gconftool-2 installed):
gconftool-2 --load=gedit_php_highlight.xml /apps/gedit-2/preferences/syntax_highlighting/PHP
- GtkSourceView has default colors it'll use for syntax
highlighting. However, you can customize it here for gedit.
Personally, I like to modify the PHP highlighting to look
similiar to the PHP highlighting as PHP would output it (as
seen in the PHP manual and on zend.com). If you would like to
use my PHP color scheme, download
gedit_php_highlight.xml and execute this command (note:
you will need gconftool-2 installed):
Plugins
Gedit supports plugins written in C or Python. There are numerous plug-ins included with the gedit package, and many more available at the Gedit/Plugins page. Gedit has a "side pane" and a "bottom pane" which can be filled with various plugins. Furthermore, plugins can embed themselves into gedit menus and/or manipulate the text and files. There's almost nothing that cannot be accomplished by finding or writing a plugin.
I won't go through all the plugins here, just some of the common ones I use which might require additional tweaking for the web developer.
Symbol Browser
File Browser Pane
One of the main things I look for in an editor other than stability and syntax highlighting is a file manager in the side pane (shown in the screen shot at the beginning of this post). This is accomplished in gedit using the File Browser Plugin. This plugin is shipped with gedit. To enable it, open up preferences from the 'Edit' > 'Preferences' menu. Next, click the 'Plugins' tab and check the box next to 'File Browser Pane'.
Once this is done, you should have a file browser pane in the left side of gedit (Press F9 to toggle visibility of the left pane).
In this file browser pane is "bookmarks" which are part of your GNOME desktop environment. You can add FTP and SSH connections and edit files live on your server (very carefully!). You can connect to a server from the GNOME menu 'Places' > 'Connect to server...' or from within a Nautilus window.
There is one setback here. GnomeVFS, the framework on which this works, has some bugs and possibly security issues when working on non-secure FTP connections. Therefore, when you're working on a site via FTP in gedit, you will not be able to save your document. (The icons for folders might not show up either).
In order to get gedit to write to FTP sites (which you should do at your own risk) you must change the a gedit setting not available through a dialog box. You'll need to either use the command-line gconf tool or the GUI Configuration Editor. You'll be changing:
/apps/gedit-2/preferences/editor/save/writable_vfs_schemes/
By default, FTP is not in the list. Simply add "ftp" to the comma-separated list and viola! Gedit now can read AND write to your FTP server.
Tag List
The tag list also shows up in the side pane and includes a list of--well, of anything. By clicking an item in the list, it is inserted into your code. Just like the File Browser Pane, the Tag List must first be enabled on the 'Plugins' tab in Preferences. I have tweaked this list (simple XML files) to suit my needs which include:
- CSS Properties
- PHP Functions
- XHTML Elements
- XHTML Attributes
To update the contents of the tagslist, you will first need to download my tag files (gedit_webdev_tags-0.1.tar.gz) and copy them to wherever your gedit tags are stored. On ubuntu, it's in /usr/share/gedit-2/taglist/
Download:
gedit_webdev_tags-0.1.tar.gz
(or)
wget http://www.micahcarrick.com/files/gedit_webdev_tags-0.1.tar.gz tar -xzf gedit_webdev_tags-0.1.tar.gz cd gedit_webdev_tags-0.1 sudo cp *.tags /usr/share/gedit-2/taglist/
External Tools
This is where things become interesting. The external tools plugin allows you to manipulate text by putting it through an external command of your choosing. Oh the possibilities. This plugin is enabled like the other plugins. Once it's enabled, the custom tools are available from the 'Tools' menu. You can configure your tools from External Tools Manager at 'Tools' > 'External Tools...'
If you want, you can download my external tools and copy them to ~/.gnome2/gedit/
Download:
Here are the ones that I have setup on my system for web development:
-
This will check your XHTML code and ensure it's valid. Any
errors or warnings will show up in the bottom pane of gedit.
You'll need to install Tidy. Tidy is usually
available via your distribution's package manager.
Name: Validate HTML
Description:Validate HTML using Tidy.
Shortcut Key: Commands:
tidy -utf8 -e -q
Input: Current document Output: Display in bottom pane Applicability: All documents -
This will reformat your XHTML code and ensure it's valid. It puts the reformatted code into a new document. You'll need to install Tidy. Tidy is usually available via your distribution's package manager.
Name: Beautify HTML Description: Beautify HTML using Tidy. Shortcut Key: Commands:tidy -utf8 -i -w 80 -c -q -asxhtml
Input: Current document Output: Create new document Applicability: All documents -
This will reformat your PHP document to "clean it up" using customizable settings. It puts the reformatted code into a new document. You'll need to have PEAR installed along with the PHP_Beautifier PEAR package.
Name: Beautify PHP Description: Use PHP_Beautifier to format PHP code. Shortcut Key: Commands:php_beautifier -s4 -l "ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)"
Input: Current document Output: Create new document Applicability: All documents -
This just uses PHP command line to parse the document and ensure there aren't any parse errors such as a missing quote, semi-colon, bracket, etc. You'll need to have PHP installed. Shows any errors in the gedit bottom pane.
Name: Check the PHP syntax. Description: PHP Syntax Check Shortcut Key: Commands:php -l
Input: Current document Output: Display in bottom pane Applicability: All documents -
This will take the word that is highlighted in the current document and look it up in the PHP manual function reference. For example, when you're not sure what parameters to pass to the strpos function, highlight it in your document and select 'Tools' > 'PHP Function Lookup'. Assumes you have Firefox. You can update the command for whatever browser your prefer.
Name: PHP Function Lookup Description: Look up current function in the PHP manual Shortcut Key: Commands:xargs -I '{}' firefox \ 'http://www.php.net/search.php?lang=en&show=quickref&pattern={}'Input: Current word Output: Display in bottom pane Applicability: All documents
As you can see, you have immense power to add your own custom features to suite your needs using the External Tools plugin.
Additional PluginsAs I mentioned earlier, there are many more plugins suited for web development, however, they are all pretty self explanatory. The other plugins that I personally have enabled are:
- Color Picker - Pops up a GTK+ color picker dialog and inserts the HTML hex code into the document.
- Embedded Terminal - I often have a SSH connection to my server in the embedded terminal allowing me to view logs, search within all files, etc.
- Gemini - This plugin makes gedit behave like TextMate on OSX. A common plugin for Ruby on Rails developers who are used to those quotes, brackets, parentheses, etc. being automatically closed.
- Snippets - A snippet library where snippets can have "tab triggers". This allows you to type a few characters and the tab key which will insert an entire snippet of code (such as a switch structure or for loop)
- Modelines - Allows you to embed a vi or emacs modeline within a comment at the head of the document. Then, the tab spaces and character(s) are determined by this mode line and not the global settings specified in the preferences dialog. So you can use one modeline for 2 space indentation in html files and another modeline for 4 space indentation in a php file.
Corrections and Notes
I got some feedback via gedit-list mailing list.
First, a very cool Tidy plugin:
I also use gedit for HTML editing, but prefer not to run HTML Tidy through external tools, but rather through a dedicated plugin (http://www.eng.tau.ac.il/~atavory/gedit-plugins/html-tidy/). This allows running tidy to check stuff, and being able to click on the bottom pane to go directly to the error/warning. Also, if HTML Tidy is used to modify an existing file, and something is very botched, then it can simply erase the original contents entirely. As far as I understand, running it through external tools consequently necessitates output to a new document, which I personally find less convenient. Finally, as HTML Tidy modifies the document, the plugin tries to guess the change to the cursor position, and move the cursor to the correct place.
Some good news about Gedit 2.20:
So with that, here is are my external tools if you want to download them:Great post. Anyway, did you know that - with gedit 2.20+ you can create a theme for your colours instead of customizing the colours in gconf ? - with gedit 2.18+ you can share external tools you create by copying the relevant files in ~/.gnome2/gedit/tools ?

96 Comments about "Customizing gedit as a Web Developer's IDE"
RSS Feed
For those looking for Ctrl-Tab functionality in gedit, I just found the right plugin: http://live.gnome.org/Gedit/Plugins?action=AttachFile&do=get&target=tabswitch.tar.gz
(link from comments in http://live.gnome.org/Gedit/KeyboardShortcuts ; there's also a link to a Ctrl-PgUp, PgDown plugin on that page)
Me too. Trying to find a fix right now, might switch to something else if I don't...
@jimcooncat: Alt-# shortcuts are not really the same. I want to cycle through tabs, not remember their individual numbers. Scrolling is uncomfortable, because it forces me to take my hands off the keyboard.
I hope they'll sort out the shortcuts soon. According to the link you posted, this should have started in Edgy, but I understand they ran into complications...
Thanks for the infos, you are a life saver ;)
#!/bin/sh
xargs -I '{}' firefox \
'http://api.drupal.org/api/function/{}/6'
Will look up drupal functions just like the tool for php above
Gconf is installed and I am running Feisty under Gnome
After further search I've stumbled upon this plugin, which I think deserves to be included in the list: Gedit File Search Plugin http://oliver.github.com/gedit-file-search/
Thanks to all gedit contributors.
To see the icons in the edit symbol browser, put them to: /root/.gnome2/gedit
It took me a while, so I am trying to save your time :D
Been having trouble getting this installed on Ubuntu 9.10 karmic koala. Let me know if you want me to send you anything to help you debug, should you choose to.
Gedit binary installation is tested in (K)Ubuntu 9.10 Karmic Koala distribution --> Works fine!
I use gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz package from http://sourceforge.net/projects/symbol-browser/
K(Ubuntu) means, that I first install Ubuntu 9.10(Gnome) and after that KDE desktop. (KDE 4.3.2)
Why? Now I have both desktops in use.
/usr/share/gedit-2.0/plugins/taglist/
I dropped them in there and it worked perfectly.
also, I'm new to the whole linux and using root thing. So for those others like me ~/ means your home/name/ directory.
Nice article.
I tried the the things you told, but i am getting this error
** (gedit:7042): CRITICAL **: Could not execute ctags: Failed to execute child process "ctags" (No such file or directory) and my symbol table remains empty.
I am using gedit 2.26 is this error because of it
Also a suggestion can u put prototype along with function name, it will be handy.
Much appreciated!
Here's what I've been looking for an editor or IDE which gedit has:
- PHP syntax highlighting
- PHP syntax checker
- FTP and SFTP file editing and tree-view browser
- Autocomplete
- Inserting snippets
- Brackets matching
Wishlist:
1. Code folding
2. Search and Replace text in files
When I don't need PHP syntax checker and remote file editing I use Quanta.
Thanks for the remote site editing tip!
I'm much interesing about your last snippet
xargs -I '{}' firefox
'http://www.php.net/search.php?lang=en&show=quickref&pattern={}'
it's not working
How to get celected or current word?
I need to run command
cat somefile | grep {} but i'ts not working
This has really helped me a great deal.
Now all we need are:
1. Code folding. Geany and Quanta Plus have me spoiled.
2. I forgot which editor did this, but if I had my insertion point at a starting div, the editor would highlight the closing div for me. Very easy to visually identify where my blocks ended.
Otherwise, great editor! Great tips!
:)
definitely souped up my gedit even more!
Something for anyone else that is getting the "symbol browser" option greyed out when they cilck on it...
Ubuntu Intrepid. I tried (and failed) to compile from source. Then i got the binaries and placed them in the /home/myname/.gnome2/gedit/ folder. The option in plugins was still greyed out.
Then i went looking for the gedit system folder and placed them in their... no joy. My laptop is an AMD64 so i was back and foward placing and removing different binaries here and there and lost many nights recently.
I just found out what I did wrong (incase somebody else gets the greyed out option in plugins) There are two gedit folders. one is lib/gedit-2 and the other is share/gedit-2. There shouldn't be any of the symbolbrowser files in either of these, only in /home/myname/.gnome2/gedit/
remove any symbolbrowser files and symbol folders from...
/usr/share/gedit-2
and
/usr/lib/gedit-2
hope this helps someone. Sometimes the only way to learn is to f* it up and fix it again. lol ;)
Can't believe there's been a viable simple web development IDE on Ubuntu all along. This guide is part of the reason why I'm moving to Linux now for Web Development for good!
http://sourceforge.net/projects/gedit-autocomp
I tried to change the following line in the /usr/share/gtksourceview-2.0/language-specs/html.lang file:
*.html;*.htm
to
*.html;*.htm;*.tpl
which didn't affect gedit.
Any other suggestions?
Do you know any plugin that closes XHTML tags? I can't install your list of tags in Fedora 10, this has exist th same directory /usr/share/gedit-2/taglist but there is only files in this directory. gz. What I do?
Cheers!
Jayme Ayres
I edit .htaccess and other hidden files all the time. If you're using the file browser plugin, right-click to get the context menu, select 'Filter' and check 'Show Hidden Files'.
For the Open/Save dialog, same thing almost, right-click and choose 'Show Hidden Files'.
Cheers.
I've only been using Ubuntu for a couple of weeks. The chief geek still uses Windows, where Blumentals WeBuilder edits hidden files without difficulty.
T.
This will make the change from OSX a lot easier.
cheers
But there are still some little things I can't get used to. Maybe someone knows how to fix em?
- Is there a way to specify the "cursor jumping style" (when you hit ctrl+left and ctrl+right)? In gedit the bevaviour is slightly different than in other editors...
- How can i use the taglist by keyboard? i.e. a autocompletion based on the taglist. probably i'm just to stupid to figure it out?
- The class browser doesn't list my class-attributes in PHP :( I applied the changes stated above to have it work at all with php...
Would be nice, if someone could help me with that!
But there are still some little things I can't get used to. Maybe someone knows how to fix em?
- Is there a way to specify the "cursor jumping style" (when you hit ctrl+> and ctrl+
http://my.opera.com/area42/blog/comparing-files-using-gedit
* SearchMonkey allows for RegEx searches in entire directory trees. Search results
can be opened in gedit with a double click.
* Meld is a great diff/merge tool that works great with SVN repositories
* And finally RapidSVN works great to check out said repositories
Combine everything and we're coming dangerously close to a fast/stable/open ZendStudio/Eclipse alternative.
Two features that I would like is popup hints as you type for php, html, etc and secondly how can I add "New PHP" doc, "New HTML" doc (to the File menu), etc so that the untitled file will already have the right extension (.php , .html) and hence make the highlighting and autocompletion work easier.
Thanks once again.
Keep up the good work!
Regards,
Christos
Enough babling.
Once again well done mate for this piece of advice you have here. :)
Gedit cuts it for me. It is well-intergrated and does lots of usefull stuff. It's a shame that the plugins are scattered around the web and there's no repo system to add/remove them at will.
I would like to suggest also another usefull plugin for gedit as web development IDE:
<a href='http://alexandredasilva.wordpress.com/gedit-todo-list-plugin/gedit-todo-plugin-english/' rel="nofollow">Alexander Da Silva's TODO list</a>
it's good to be able to get back to your code and view all those tips you've left in there inside comments blocks in an organized list that shows all work noted to be done in all the files of a project. It is a bit trickier to install than just tar xvf but it's worth it.
Yes, I've tried screem... in fact, I've tried most of the free IDEs available for Linux. I prefer Gedit still-- primarily for stability (I can't have it crashing mid-work) and how clean it is. I feel a lot of the other IDEs and editors try to cram too much prematurely resulting in an unstable, cluttered application.
cheers
Here is a presentation of its autocompletion:
http://youtube.com/watch?v=rQGs-dVDd08
For high quality video: http://www.box.net/shared/q2dxnj6sk0
I found out the cause : your symbol browser plugin :) It`s very useful, but it seems that disabling it removes the slow saving problem. Could you please look into it when you have some time? Or maybe it`s the Python interpreter itself?
Thank you!
:)
I don't have this problem. I work on files with 1000+ lines every day. Only remove files over SSH take a bit when they're that big. I can even save pretty large local files (40,000 lines) without it affecting any flow.
I`m oscillating between Quanta Plus and Gedit. Both come with great features and plugins. But there`s a problem : gedit is VERY slow on saving files. A 1000-line *.php file (~35KB) requires about 1.5 seconds to save (P-M 2.0GHz, 5400rpm HDD, nothing else accessing the HDD, RAM not full, processor at 20% use) ... Does anyone have a solution to that? I have to say, other than this small inconvenience, Gedit is the way to go :)
I would like to have gedit work so that when the cursor is in a url (such as www.ubuntuforums.org, either with "http://" or just "www.") it can select that URL, pass the URL to the browser, and have the browser open that URL -- or open it in a new tab (if the browser is already open).
I need a simple solution. I'm not ready to write a plugin for gedit from scratch -- not even close. I'm still learning Ubuntu.
http://ubuntuforums.org/showthread.php?t=689632
For me it alway was a big disgrace, that GEdit can load fron FTP but not save to. Thanks to your article, now i know, it was only done by the Gnome-guys not allowing this!
Recently I've been looking for a more dedicated web IDE, but after following some of your tips, gedit is refreshing to me!
Thanks for this insightful article.
When it saves an existing file first it delete the file and then recreate it instead of editing
Normally this is good enough but if you work with Zope/Plone as me you will know how bad is this
I wonder why a lot of editor in linux do the same
Did anyone know how to solve this issue?
Thanks for your work!
regexxer - search and replace in files
http://regexxer.sourceforge.net/
#!/bin/sh
regexxer --hidden --ignore-case --line-number --pattern=$GEDIT_CURRENT_DOCUMENT_NAME --regex=$GEDIT_CURRENT_WORD $GEDIT_CURRENT_DOCUMENT_DIR &
pysnippet - your own code snippets
http://sourceforge.net/projects/pysnippet/
#!/bin/sh
python /usr/bin/pysnippet.py &
Renaming files
#!/bin/sh
pyrenamer --root $GEDIT_CURRENT_DOCUMENT_DIR &
First, syntax highlighting is still there but has changed. It's is now much more intelligent. For example, it will now highlight PHP embedded within HTML. It is now using color "themes" which are customizable as well. Ask on the gnome-devtools for information on that.
Second, yes, bluefish is a web development IDE for Gnome. For others, you might want to read my other post on web development in Linux: http://www.micahcarrick.com/09-28-2007/web-development-linux.html There I list several of the IDEs you might use (Aptana, gPHPEdit, Eclipse, Quanta Plus, etc.)
Bluefish is a lot of peoples preference for good reason. I used it for about a year before I discovered what Gedit could do. The reason I now prefer Gedit is for it's elegant simplicity and stability. It never crashes opening huge (server log) files, it never gives me trouble with different encodings, it never crashes on me when working on remote files, I only enable the plugins for features I want to use--there's not a lot of clutter for features I wouldn't even use. So it's just a matter of preference.
http://bluefish.openoffice.nl/
http://ubuntuforums.org/showthread.php?t=588593&highlight=gedit+syntax+highlighting
I tried the Gnome/KDE web dev IDEs. They are both pretty noob oriented. Gedit is great.
Here's a small script I wrote to get the source of a web page.
#!/bin/bash
zenity --entry --title="URL" --text="Enter URL to download." > twp_000012
wget `cat twp_000012` -O twp_000012 >/dev/null 2>&1
cat twp_000012
rm twp_000012
I wonder if one could do this in gedit.
Vikas
Using the Gnome Configuration Editor you can set the last recent files to at
/apps/gedit-2/preferences/ui/recents/max_recents
The standard value 5 isn't much, i prefer 20.
Yeah I'm really loving gedit, mainly because it can juggle files from my 3 servers at the same time and I don't have to hop into a FTP/SSH client (*shudders*) to upload every time I save.
Code completion (like dreamweaver) for HTML and CSS would be great (I think somebody's making a plugin - could be wrong) as well as a PHP (et al) parameter lookup (eg you type a function name and it tells you what arguments you need to pass it, again like Dreamweaver.
http://my.opera.com/area42/blog/webdev-command-line-tool
others IDE, editors running.
And I'm very surprised with gEdit. I really thought it was just a
some editor out there for the gnome toolkit and for the people to have
something to write on.
Nice work!
-----
line 28: from parser_php import PHPParser
line 72: self.tabwatch.register_parser("PHP",PHPParser())
-----
Bug is reported as well.
You can use Alt-1, Alt-2, etc. to get to different tabs. You can also move the mouse to the tab area and use the scrollwheel to cycle between tabs.
This usability shortcoming is being addressed, someday.
https://wiki.ubuntu.com/TabConsistency
On FreeBSD 6.1 the files are copied to /usr/X11R6/share/gnome/gedit-2/taglist .
The main thing which I dont like is that you cannot switch between opended documents with Ctrl+Tab. I used to use this and I couldn't manage to set this.
Then I found Komodo Edit from ActiveState and I was reborn.
komodo is loading quite slow in the beffining but it's quite handy especially for me.
PHP-in-html etc are properly supported in gedit 2.20 and different tab width per document can be done with modelines.
Feel free to submit your improved tags collections upstream.
ciao
Leave a Comment about "Customizing gedit as a Web Developer's IDE"