The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
RubyBuntu -4- Make gedit better than any IDE ;)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
RubyBuntu -4- Make gedit better than any IDE ;) Posted: Apr 29, 2010 7:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: RubyBuntu -4- Make gedit better than any IDE ;)
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

You can, of course, use an IDE for coding – but reconsider it: After hours of initialization, it tries to do everything for you… Somewhere in the never ending menu jungle… And you need to click all the time… Stop! Focus on the gist! You want to write code!

So, as an ubuntu developer, you have the following options:

  • Even so, get an IDE and be happy with it. I am not saying that all IDEs are bad, for example, Netbeans is quite cool.
  • Become a vim or emacs freak. Start being productive in thousand years.
  • Buy a Mac and buy TextMate.No, don’t do that!
  • Use gedit, because it is a slim, powerful, flexible, fast, pretty and stable editor ;)

Getting the plugins

gedit is the gnome standard editor so it is already installed on a fresh ubuntu. But the fun begins with the plugins, so you should get more of them. There are two ubuntu packages with lots of popular plugins: gedit-plugins and gedit-gmate. The latter is found in the ubuntu on rails ppa. Add/Install:

sudo add-apt-repository ppa:ubuntu-on-rails
sudo apt-get update
sudo apt-get install gedit-plugins gedit-gmate

Installing plugins manually

There are many other plugins available and installing them is quite easy. Just place the downloaded files of the plugin at: ~/.gnome2/gedit/plugins. Pay attention that the .plugin file must lay exactly in the directory. In most cases it comes with an additional .py file and/or a folder named after the plugin.

Basic settings

At first you should configure some basic settings common for Ruby programming at Edit/Preferences:

View Display line numbers on
View Highlight current line on
View Highlight matching bracket on
Editor Tab width 2
Editor Insert spaces instead of tabs on
Editor Enable automatic indentation on

At the Font & Colors tab you can choose some colors that suit you. I use the great “Railscasts Improved”.

Hot hot keys

Before getting into the plugins, let me highlight that good shortcuts for good features are very important. What is the use of a plugin that you do not use, because you do not know how to use?

ubuntu offers a nice way to change menu shortcuts: The global Editable menu shortcuts setting. It allows you to change a shortcut of a menu item by moving the mouse over the item and pressing the desired shortcut.

Unfortunately, it has disappeared in ubuntu 10.4 from the appearance settings. But it is not lost, it is just hidden. You can get it back with the gconf-editor by activating the option /desktop/gnome/interface/can_change_accels:

activate desktop/gnome/interface/can_change_accels

Plugin list

You can activate each of the plugins at Edit/Preferences/Plugins. Every plugin in the list without a download link is in one of the above packages. For some plugins I added a shortcut suggestion.

Essential Plugins

You should use these ;)

Code comment

Comment out whole blocks of code with one keystroke.
Edit/Comment Code Strg+#
Edit/Uncomment Code Strg+Alt+#

Find In Files

This does a full text search in the specified directory. Especially needed, when working with code you do not know.
Search/Find in files Strg+Shift+F

Indent Lines

This lets you indent the current line(s). Very useful. Unfortunately, it has been removed in ubuntu 10.4, because it is now possible to indent marked text with the Tab key. However, I prefer the old plugin (download), because you can change the shortcut and you are also able to indent single lines. It really is fun to move around text with Alt+ArrowKeys :)
Edit/Indent Alt+Right
Edit/Unindent Alt+Left

Rails Extract Partial

Mark some text, press the shortcut, enter a partial name – a must have for Rails developers.
Edit/Extract Partial Alt+P

Smart Indent

Auto indentation, customizable via regex. Familiar comfort.

Snap open

I think, this is the most important plugin. Press the shortcut and type the filename you want to open – it integrates with the file browser pane and searches through all files in the selected root directory. In about 9 of 10 file switchings, I use this plugin.
Search/Go to File or Snap/Open Strg+O

Snippets

Another wonderful helper. It lets you easily include templates by typing an alias and pressing Tab. Furthermore, it puts the cursor to the right spot (e.g. between the html tags). Some templates even have more cursor spots (hit tab again). Alternatively, you can press Strg+Space to get a list of available aliases (also nice for learning them). You can easily customize the snippets at Tools/Manage Snippets…

Word completion

This plugin searches trough all open documents (which are quite a lot when using Snap open) and offers known words for completion. Press Return to choose one.

Maybe you like it?

These plugins might be perfect for you – or annoying. I use some of them.

Embedded Terminal

This adds the gnome-terminal in the bottom pane (Strg+F9). I rather have my terminals in extra windows, but it is ok for a little irb.

External Tools

Lets you execute any commands! The definite toy for power users :). For example, you can easily execute your Ruby code with this snippet:
#!/bin/sh
ruby
Input: Current Document
Output: Display in bottom pane
Change ruby to ruby -c to only check the syntax. You can find lots of more External Tools snippets at the gnome wiki. Again, I prefer using an external terminal in most cases.

Gemini

Automatically adds common characters like closing brackets – but there are occasions, where it does the wrong thing. Nevertheless, I like it.

Rails Hotkeys

Offers Rails-specific shortcuts. Hit Strg+Shift+R and then F1 to see a list of available ones. It is a good idea, but in most cases, Snap open just does the job more intuitive.

Reopen Tabs

Download. Opens all the tabs from last time, when gedit starts. Nice, to quickly get back into work, but pretty slow, when there are lots of open tabs…

The icing on the cake!

Plugins in this category are nice to have, but probably not that important

Color Picker

Press shortcut when cursor is on a color to get a nice color picker. Useful for web/css development.

Code Formatter

Download. Reindent spaghetti Ruby code with on keystroke.

Open Folder

Download. Opens the folder of the current active document.
Tools/Open folder Alt+O

Open URI Context Menu

Download. Adds “Open link” to link context menus.

TODO List

Hit the shortcut and it displays a list if your TODO/FIXME annotations (like Snap open, it integrates with the file browser). Do it from time to time ;)

There are a lot of more plugins and resources available. Some links you could check out, if you want more:

Rails Footnotes °_°

In the end, there is some nice extra sugar for Rails-developer: The rails-footnotes gem! It adds interesting informations about the current Rails request to the bottom of each rendered browser page.. It also provides helpful links to associated files – which open in gedit!

footnotes are added at the bottom of every page

But that is still not everything… When you get an error page, you can click on each referenced line and gedit will open the accordant document and jump to the line!

You can click on an error..

...and gedit opens the accordant file on the right line

Total convenience! I gained much productivity using this tool.

Install:

sudo gem install rails-footnotes-linux

Add this line to the Rails project’s config/environments/development.rb:

config.gem 'rails-footnotes-linux', :lib => 'rails-footnotes'

Not working for Rails 3, yet

That’s it!

At this spot, a big thank you to all people who developed gedit, translated it, wrote plugins or otherwise contributed. Without you guys, gedit would not be such a great editor!

CC-BY (DE)

Read: RubyBuntu -4- Make gedit better than any IDE ;)

Topic: RubyBuntu -3- Be one with your command line! Previous Topic   Next Topic Topic: Paul Barry Winner RPCFN #8

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use