|Clik-click tap, clik-click tap, clik-click tap. A team mate is performing some kind of repetitive operation with text and it’s becoming more and more annoying. Good news, there’s a way to keep your mental sanity and help this guy to be more productive: replace him with a sed/awk script teach him how to use Vim macros!|
Vim macros can repeat for you a sequence of commands. Press qq to start recording, then q again to stop. Use @q to execute a macro. Let’s try it:
This – random garbage
is – random garbage
a – random garbage
sample – random garbage
text – random garbage
So, how would you get rid of the random garbage? Move the cursor to the beggining of the first line, press qq to start recording then f- to move the cursor to the dash and d$ to delete the rest of the line. Now move the cursor to the begging of the next line (0j) and press q to stop recording. Now press 4@q to repeat the macro for times and check the results; you should have something like this:
Neat, huh? You can also store any number of macros using a different letter after the q to start recording, for example qn to record and @n to execute. Also, use @@ to execute once again the last executed macro (from any buffer).
There are some more things you can do with macros (like editing before executing one) but the best source for that is the manual.
|Working  on a C++ project with Oracle I found that Valgrind reported lots of warnings related to OCI, for which, regardless of being false positives  or not, there’s little I can do about (other than migrating to MySQL, that is). As the error report kept growing I found that Valgrind will refuse to keep track of new errors after a million or so:
The solution in this case is a suppresions file for Valgrind. After spending a good deal of time unsuccsesfuly trying to get one I had to do it myself and upload it for the next one to run into this problem:
– Link to the file: Valgrind / OCI suppressions.
Let’s face it, Vim is the best editor in the world, and from now on there’ll be a spot in the homepage with a “Vim Tip of the Week” (check the sidebar).
For the first one a basic tip: Moving to a letter
While in command mode press ‘f‘ and any other letter; the cursor will move to the first occurence of this letter. This can be combined with other commands and a number of repetitions (e.g. ‘d2f.‘, to delete until the second dot).
As a sidenote, I guess there must be a Word Press plugin to display the latest post in a category but I coudn’t find it, so I hacked my own: tip-of-the-week
|Subo una presentación que usamos para dar una charla de introducción a GNU/Linux en la UTN a principios del 2008 con el grupo GNUTN, orientada al desarrollo. La charla salió muy bien pero todavía no hubo quorum para armar una nueva.|
También dejo link en la sección de artículos.
|Una presentación que armé para el trabajo con una introducción a Valgrind, herramienta para profiling y debugging, principalmente para C/C++ en Linux (es posible usarlo con otros lenguajes pero nunca probé):|
También dejo el link en la sección de artículos.