views:

649

answers:

6

As a long time VIM user, it pains me to have to use the Delphi IDE. At least with Visual Studio there's ViEmu which works well.

So, do you have any advice for getting by in the Delphi IDE when you're so used to VI?

Any settings that you'd recommend to make things a little more familiar?

Any specific keyboard shortcuts that can save time and mouse clicks?

A: 

There are a lot of keyboard shortcuts in Delphi. Some of them came from the turbo pascal time (and they came from the ancient wordstar period).

Just beware that there are several modes that you can use and each has its own settings:

  • default
  • IDE classic
  • BRIEF emulation
  • Epsilon emulation
  • Visual studio (tm) emulation
  • Visual basic (tm) emulation
  • New IDE emacs
  • New IDE classic

Unfortunately It looks like these are hard coded so it is not possible to change it.

The help has a list although it is not complete.

Gamecat
But is any of them even remotely like Vi?
Rob Kennedy
The point is that VIM has modes where keystrokes don't even make it into the edited text, they are just commands. Like "15dd" to delete fifteen lines (not sure about the proper incantation, though). Somehow I doubt the editor DLL of Delphi can be convinced to do that.
mghie
A: 

Here's my favourites.

  • CTRL-SHIFT-I to indent a block
  • CTRL-SHIFT-U to indent a block
  • CTRL-/ to comment or uncomment a block
  • CTRL-E for "search-as you type"

GExperts for a bunch of useful things, including

  • SHIFT-ALT-R to reverse a statement: a:=b; => b:=a;

And of course, Code Templates

Roddy
+2  A: 

I have come to love the refactoring-shortcuts in Delphi 2007:

CTRL+SHIFT+V - Declare variable
CTRL+SHIFT+E - Rename identifier

I also often use keyboardrecording

CTRL+SHIFT+R - Start/Stop record CTRL+SHIFT+P - Play

My favorite GExperts-shortcut was

CTRL+ALT+Z - Align lines

I have always wanted a more powerful 'Align lines' function, and fore some reason I have stoped using GExperts al thogether :-/

I guess the bookmark-shortcuts are kind of obvious

CTRL+SHIFT+1 - Set bookmark 1
CTRL+1 - Goto bookmark 1

Before I switched to Delphi 2007, I used Castalia (never upgraded, don't know why...) It extends bookmarks with a bookmark-stack, where you drop bookmarks and collect them with ESC. I liked that one.

Vegar
+1  A: 

See also question Hidden features of Delphi. Many useful shortcuts were mentioned there.

gabr
+2  A: 

AFAIK there is no single one of the various edit modes in the Delphi IDE that implements the distinction between command mode and edit mode that VI(M) has. In that light I think it would be quite difficult to write a vi edit mode for the IDE, but I'm no expert.

Having said that I need to go a little off-topic - why do you "have to use the Delphi IDE" for your editing? It does of course depend on the amount of form editing you have to do - editing Delphi forms (DFM files) in a text editor is possible, creating them in a text editor is not a good idea if you want to keep your sanity - but if you edit source code whole day you absolutely don't have to use the Delphi IDE. You can create a Makefile for your project, or use the MSBuild command line facility that the newer Delphi versions have, and do all your editing in VIM. You can even edit source code in VIM and switch to Delphi for compilation, as the IDE will detect that open files have changed outside the IDE and ask you whether to reload them, and files that not opened will be recompiled without any question when you build the project. This may even be the best compromise when you do work with forms.

Trying to have most of the source code in normal source files outside the forms of your project can even help you to prevent the kind of tight coupling between UI code and "business rules" that one sees so often in Delphi projects.

mghie
A: 

Learning the keyboard shortcuts in Delphi will save you a huge amount of time. Especially getting to know the refactoring tools, code completion, code templates, and so on... There is a nice list of keyboard shortcuts available delphi.wikia.com. I also did a video awhile back on 100 IDE Tips and Hints, which should get you started.

Alister