devxlogo

Hey, Check Out My Slick New Editor!

Hey, Check Out My Slick New Editor!

hen someone comes over to your cube and starts talking about the latest cool software, the last thing you would expect them to be excited about is a new text editor. I mean, who buys editors these days? If you want to get fancy-shmancy, you can download emacs—if you have the time to figure out how to install it and use it. Moreover, every Integrated Development Environment (IDE) these days has browsing functions, syntax highlighting, and so forth. Why would you really need more than that?

Enter SlickEdit. SlickEdit isn’t new; it’s been around for 20 years or more. If you don’t know about it yet, maybe the right person hasn’t stopped by your cube lately.

Why Switch Editors?

If your current editor works well enough for you, why switch? The answer depends on how you define “well enough.” Your current editor probably handles every editing command you think you need now, but consider the possibility that something could make you far more productive. You’ll see a few examples in a moment, but first, here are some of the reasons you might decide not to switch editors.

Mastering Powerful Tools Takes Time

If all you’ve ever used is emacs or vi, no wonder you immediately think of this excuse. Those editors do require serious learning time. Contrast that with something like Eclipse or Visual Studio, which have features designed to be discovered relatively easily.

SlickEdit combines the best of both worlds; it has custom and/or predefined keyboard navigation shortcuts combined with rich menu choices that make your world both “powerful and discoverable.”

I’m Used to

Familiarity is a perfectly valid reason: and that’s where SlickEdit’s emulation features may help you out tremendously. Look at Figure 1, and you’ll see that SlickEdit emulates most of the powerful editors available today.

 
Figure 1. SlickEdit Emulation: The options screen lets you choose to emulate nearly every popular editor.

Brief (my personal favorite) seems to have the fastest keystroke commands of any system I’ve seen, yet I have to admit that SlickEdit’s Brief emulation is superb.

Of course, the best part is not that the emulations are all defined for you—you can define your own. SlickEdit will let you attach a command to any keystroke combination using its “Key Bindings” option. After assigning a keystroke, the keyboard shortcuts immediately show up on the menus next to the commands as a reminder.

I Have to Work from My IDE

That’s understandable; however, IDEs such as Visual Studio have options that let you substitute external editors for their built-in internal ones. In other words, Visual Studio doesn’t really care what editor you use. SlickEdit can open Microsoft solution files and compile or build them and jump to compiler error lines. So while you may feel the need to work from your IDE, you may also discover that doing so is necessary only for debugging.

Author’s Note: SlickEdit also sells a nifty set of tools that integrate right into Visual Studio. Don’t rule those out if they provide what you need.

Now that you’ve seen the main reasons why you might not want to switch, the rest of this article covers a longer list of features that illustrate why you might want to consider a more powerful editor.

Regular Expression Search and Replace

This isn’t an exclusive SlickEdit feature, some other editors have it too; but if you haven’t had the opportunity to experience regular expression searches, you should really consider switching to an editor that supports the feature.

Have you ever had to change an API in a product? Not just a name change, but a calling convention change, where you have to switch or add parameters. Such change requirements can be major problems when you need to make many changes or make them in many files. In such cases, you’ll find a regular expression search/replace feature invaluable.

Many developers are familiar with using regular expressions to match patterns. At a simple level, dir *.c is a great example of one you may have used. However, you haven’t really explored the power of regular expressions until you’ve used them in a replacement pattern. Using this technique, you can define a pattern, find a match, and then use part of the pattern you’ve designated in the replacement!

 
Figure 2. Regular Expression Evaluator: This tool helps you build regular expressions interactively.

Here’s an example. You need to change a function, and so of course you also need to alter calls to that function wherever they reside in a program. This example requires changing some code that uses a less secure version of a function to a more secure equivalent. You’ll see that it’s quite easy using a regular expression replace operation.

At this point, you may be thinking, “But I don’t understand regular expressions.” That’s OK; Visual SlickEdit provides several tools that can help you build appropriate regular expressions. First, just to the right of the find and replace fields, you’ll see an arrow that—when you click it—brings up an extensive list of common expressions: everything from “match any character” to “beginning of line.” Because you also have a choice of regular expression syntax (Unix, Perl, Brief), SlickEdit can even help you understand the differences between the expression syntax in each language.

Taking help a step further, SlickEdit has a regular expression evaluator available from the Tools menu (see Figure 2).

If you open this up, you’ll find an awesome tool that helps you figure out whether you have the right syntax for a match! The regular expression evaluator is a powerful recent addition to SlickEdit. I was able to paste in some sample patterns I wanted to match in my program and then edit the regular expression until I got them to light up (see Figure 3).

 
Figure 3. Successful Pattern Match: When evaluating regular expressions, a successful test pattern match makes the pattern “light up.”

If you look carefully at the regular expression syntax at the bottom of the RegEx Evaluator dialog in Figure 3, you’ll see two “extra” parentheses around the strcat parameters. These tell SlickEdit to “remember” these matches for later. You’ll see how that works in a second.

Having created a valid and tested pattern, it’s time to do the actual find and replace. From the Edit menu select Replace (or F6 if you have Brief emulation turned on) and start typing your expression into the Find window. The example shown in Figure 4 is asking for patterns that match strcat followed by an opening parenthesis, then a group of one or more characters followed by a comma, and then another group of one or more characters followed by a closing parenthesis.

 
Figure 4. Search/Replace: This search replaces calls to the strcat function with calls to strncat.

 
Figure 5. Replace Prompt: SlickEdit’s regular expression search matched this call to strcat and shows how the replacement would look if you accept it.

Next, set the replacement string. In this case, you want to replace strcat with strncat—a more secure function that honors the size of the buffer you are copying into. (There are other, possibly better, safe string function options, but this one exists in all common C runtime libraries that I’m aware of.) Note the 1, which means “substitute the first grouping found during the search.” The 2, of course, means “substitute the second grouping found during the search.” Finally, you need to add the size of the buffer as a third parameter. When you’ve completed the dialog, click Replace, and for each match, you’ll see something similar to Figure 5.

For each match, you can determine whether you want to replace that occurrence and go onto the next. Click the Last button if this is the last replacement you want to make. The Go button functions as a “Replace All” feature, making the replacement for all available matches. With some practice, you’ll find yourself pulling this regular expression search/replace feature out of your tool belt more and more often.

Author’s Note: A little forethought is warranted if you plan to make several broad changes that may be interdependent. Sometimes such changes are easier if you make them in pieces: first replacing code with something easy to find, and then performing a second find/replace to make the final changes. If something shows up in your current replace string that you anticipate changing later, you may want to reverse the order and perform the other replace operation first.

Macro Record/Playback

SlickEdit carries out many of its commands through its slick-C programming language (note that both Brief and Emacs have their own languages as well). SlickEdit lets you write your own macros, or do a simple record / playback. This comes in handy when the syntax for find and replace gets too dicey.

As an example, instead of the find and replace above, you could write a macro that searches for strcat, places the cursor at the end of the string, and then pauses. Next you could copy the string to the clipboard or do some other editing you have planned. Continue the macro and have it paste the result of your copy, skip to the end of the line, and add a comment that the line changed.

As another example, you might write a macro that skips to the beginning of your current function, copies the name to the clipboard, inserts a standard comment header in front of it, and then pastes the name of the function. The possibilities are endless.

Refactoring

 
Figure 6. Refactoring: SlickEdit’s Quick Refactoring feature provides several options based on the code you select for refactoring.

Often, you’ll find yourself in a situation where the code you have is fine—the only problem is that when you first wrote it, you didn’t know how often you were going to repeat a sequence of operations with a common set of arguments. Now your code’s all cluttered up with repeated function calls. It’s time to refactor (see Figure 6).

Here’s where you can take advantage of SlickEdit’s convenient refactoring feature, which lets you select some lines of code and create a function out of them. When you choose this option, SlickEdit presents you with some choices (see Figure 7). Based on your selections, it can take the code you’ve selected, move that into a new function, define any variables you were using at the beginning of the function, and create parameters that allow the values to be changed by the caller. Oh, and it can also replace that spot in the code where you selected those lines with a call to the new function!

 
Figure 7. Refactoring Options: You specify exactly how SlickEdit should treat the code you’ve selected for refactoring.

 
Figure 8. Refactoring Prompt: Before making any changes, SlickEdit gives you a chance to see exactly how the change will affect your code and accept or refuse the change.

This feature is very nice—but watch the results carefully—because you may find instances where SlickEdit uses C++ references in places where a variable’s value really doesn’t need to be updated, or is already a pointer in the calling code.

Again, before it makes any changes, SlickEdit shows you exactly what it’s about to do to your code (see Figure 8) using its “diff” feature, discussed next.

Diffzilla

The diff program in SlickEdit is so powerful that’s it’s affectionately named “Diffzilla.” Diffzilla is a combination compare/merge tool that can help you resolve differences once you spot them. You can also point tools like Perforce at SlickEdit and tell it to use that as the merge or diff tool rather than its internal version.

Author’s Note: I highly recommend this if you are using Perforce’s merge tool. Diffzilla will attack files or even entire source trees, which is great if you are doing merges outside the control of your version control system, or across different instances of it.

 
Figure 9. Diffzilla Options: On the Files tab, you can browse to files with Windows Explorer or click the “B” button to operate on open files.

In Figure 8, notice that Diffzilla shows the original version on the left, and the updated version on the right. As you highlight the different changes (using the “Next Diff” button), you have options to change the line or the whole block, in either direction. Figure 9 shows the Diffzilla dialog on the Files tab.

You can choose files using Windows Explorer by clicking on the ellipsis (…) button, or clicking the “B” button, which stands for “open buffers”—the files currently open in the editor. Diffzilla makes it easy to see differences or merge code in a readable way.

Author’s Note: A new feature called “Source Diff” takes this concept a step further and attempts to refine the differences it highlights to those that would alter program execution. This feature ignores white space changes, for example. Personally, I like to see white space changes, as we have strict policies on how white space is used where I work.

Find in Files

Something as simple as finding all the files that contain a particular string can actually be challenging on Windows.

You can use Windows’ Search Companion (see Figure 10), but I find it’s sometimes inaccurate. In contrast, you’ll find SlickEdit’s Find in Files command much more useful (see Figure 11).

 
Figure 10. Windows Search: Windows search lets you search for file names and/or specific content in files.

 
Figure 11. SlickEdit File Search: SlickEdit lets you search within files not only for specific content, but also for regular expressions.

Basically, SlickEdit gives you all the power of regular expressions for searching inside files on your hard drive. It’s great for finding things quickly, and it’s both faster and more accurate than Windows search.

Browsing

 
Figure 12. Tagged Files: After identifying a set of files, you can easily browse symbols and functions that occur within that file set.

If I could pick one IDE feature that I wouldn’t want to be without, it would be source browsing. While searching through files is useful, it’s even nicer to be able to list and jump to all the occurrences of a call to see which might be erroneous, or to figure out how many files I’d have to change if that function’s call signature changed. SlickEdit not only has a great source browsing engine, it works for several languages. The C++ source browser is very nice. Using the Tools Tag Files feature, you can select several complete source trees to browse, making it very easy to jump to definitions and references in your code (see Figure 12). Tag Files includes another powerful feature: popup cues for APIs with Doxygen or Javadoc syntax!

In practice, as you type a function call, SlickEdit notices whether that function resides in its source code database (see Figure 13).

 
Figure 13. API Cues: When you type a function name, SlickEdit looks for and (if found) displays appropriate Doxygen or JavaDoc-style information about that function.

For example, if the function has a Doxygen style comment above it, you’ll see notes on the function, and notes on each parameter as you’re about to type them in. This is a great feature that works for several languages, including JavaScript. SlickEdit gives JavaScript first-class citizen status.

Other Features

As you might imagine, because SlickEdit’s been around for 20 years, this article just scratches the surface, but some other useful features include:

  • Version control integration: SlickEdit works with all major version control packages.
  • Support for debugging within the editor: You can compile, run, and debug right within the editor.
  • Configurable file types: SlickEdit’s file extension configuration associates file types with different compilers or formatting based on the language you’re using. SlickEdit provides good defaults for most popular languages.
  • Comprehensive formatting: You’ll find extensive support for your personal code-formatting preferences—even for comments. Figure 14 gives you an idea of the range of formatting options available. You can even dictate brace style. When you type braces, they can open up the way you like and place the cursor where you want. Some people despise this feature; if you do, just turn it off.
  •  
    Figure 14. Formatting Preferences: SlickEdit provides an extensive set of formatting options that let you format code or comments exactly the way you like.

     
    Figure 15. Visual Problem Clues: Here, the red color helps to identify a referenced but undefined variable (note the misspelling).

  • Problem highlighting: SlickEdit’s source browser engine can note when code you’ve typed is slightly off. For example, when making Doxygen-aware comments, if the comments aren’t green you probably forgot the extra asterisk. As another example, in Figure 15, a referenced but undefined variable is highlighted in red.
  • Convenient command line: SlickEdit provides a command line that you reach with the Esc key, so you can type Slick-C commands directly.

SlickEdit is a truly powerful editor. There probably isn’t anyone on the planet who knows all the features in this product. Despite its power, SlickEdit manages to keep all that functionality out of your way until you need it. That may be the most important feature of all!

See also  AI's Impact on Banking: Customer Experience and Efficiency
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist