background preloader

Knowledge

Facebook Twitter

TheBrain.com - Welcome to TheBrain. SCAN » Home. CmapTools - Home Page Cmap.html. Gnizr - Google Code. Visual Understanding Environment. DeepaMehta -- Homepage. Efficient Editing With vim. Why, oh WHY, do those #?@! nutheads use vi? The VI Gang Sign by Jon Beltran de Heredia, May 16th, 2007 Yes, even if you can't believe it, there are a lot fans of the 30-years-old vi editor (or its more recent, just-15-years-old, best clone & great improvement, vim).

No, they are not dinosaurs who don't want to catch up with the times - the community of vi users just keeps growing: myself, I only got started 2 years ago (after over 10 years of being a professional programmer). Friends of mine are converting today. Heck, most vi users were not even born when vi was written! Yes, there are definite reasons why the vi/vim editing model is just superior to any other out there. Misconception #1: modal editing The first time you stumble into vi or vim, you are shocked and disgusted that you have to use 'i' to start typing text. Turns out, this is just a completely wrong way to use vi or vim.

Let me explain the philosophy behind this. And now we come to insert commands. Example #1: the wonderful dot command Let's see a concrete example. Faster PHP Apps—Profile Your Code with Xdebug. Object-oriented programming is well and truly in fashion, and PHP is no exception. So you’ve adopted the proper design patterns, built your site on the latest PHP framework, and have your database access abstracted so far that you’ve forgotten SQL. What’s Going On? When you first move towards object-oriented programming, the first thing you might notice is that you can give yourself a headache trying to follow the execution path through your code and the framework it’s built on. The next thing you might notice is that your site isn’t any faster – in fact perhaps it’s slower than it was. Object-oriented programming generally aims to improve the quality, maintainability and reusability of code, but sometimes this comes at the price of some raw speed. So we’ve got potentially slower code, and we can no longer just open up our simple PHP script and follow its execution from the top of the file to the bottom.

How do we figure out exactly what’s going on inside? Xdebug WinCacheGrind KCachegrind. Keyboard shortcuts in OS X. Wiki: Scite Macro Expander. SciTE Macro expansion facility I always enjoyed the C preprocessor macro facility. To my eye, this macro makes C code more readable and less error-prone: #define FOR(i,n) for(i = 0; i < (n); i++) Unfortunately, disciplined use of statement macros fell into disfavour due to abuse, and C++ stylists are generally against them (Stroustrup as usual takes a more pragmatic line) The SciTE Lua Macro expansion facility is a simple macro preprocessor which expands macros in the current buffer, rather like abbreviations.

Macro.subst.1=for(i,n)=for(i = 0; i < n; i++) and type FOR(k,10) in the buffer, followed by 'Expand Macro' (Alt+Enter). Since it's a single-pass expansion which never happens automatically, there's no problem in using keywords like 'for' here. Line feeds are indicated using '\n' in the macro definition and you can always use a backslash to split the definition over several lines. macro.subst.2=if(cond)=if(cond) { \n } else { \n } macro.subst.3=date=$eval(os.date()) Setting up Examples where. An App A Day : Jedi Window Dock.