Tag Archives: Linux

Vim tips and tricks: HTML table re-ordering

Suppose you have an HTML table on a static website, not dynamically created. It shows a grid of thumbnail photos in table cells. The code was something like the following:

<table>
 <tr>
 <td><a href="photo/photo01.html"><img src="photo/photo01.jpg" alt="" /></a></td>
 <td><a href="photo/photo02.html"><img src="photo/photo02.jpg" alt="" /></a></td>
 <td><a href="photo/photo03.html"><img src="photo/photo03.jpg" alt="" /></a></td>
 <td><a href="photo/photo04.html"><img src="photo/photo04.jpg" alt="" /></a></td>
 <td><a href="photo/photo05.html"><img src="photo/photo05.jpg" alt="" /></a></td>
 </tr>
 <tr>
 <td><a href="photo/photo06.html"><img src="photo/photo06.jpg" alt="" /></a></td>
 <td><a href="photo/photo07.html"><img src="photo/photo07.jpg" alt="" /></a></td>
 <td><a href="photo/photo08.html"><img src="photo/photo08.jpg" alt="" /></a></td>
 <td><a href="photo/photo09.html"><img src="photo/photo09.jpg" alt="" /></a></td>
 <td><a href="photo/photo10.html"><img src="photo/photo10.jpg" alt="" /></a></td>
 </tr>
 <!-- etc... -->
</table>

Yes, ouch!

There are hundreds of photos, spread over several pages in several HTML files, and you want to put them all on one page. You also want to change the number of columns of the thumbnail grid. How are you going to do this in the most efficient way possible, without turning the code into a dynamically generated code? Read on to learn more, using grep and vim!

Continue reading Vim tips and tricks: HTML table re-ordering

tmux – an awesome little tool

If you do a lot of programming from the Linux console, you’ll certainly appreciate the power of tmux. It is a terminal multiplexer, which means that it can create multiple virtual consoles within a single terminal shell. Since these virtual consoles are not bound to a terminal, they will keep running in the background, even if you close the terminal you started it in. This means that you can detach these consoles, and re-attach them in another terminal session.

For example, imagine you are working on some project on a development server. You log into that server over SSH from your office, create a tmux session, and do your coding in vim in there. Then you detach the session, and log out from the server to go home. Back at home, you log into the development server again, and re-attach the tmux session, and you see the vim session back where you left it. Not that I suggest you to work from home, but it is a good example of how you can continue your work or session from anywhere.

Tmux in action. Two vim sessions and a MongoDB console.
Tmux in action. Two vim sessions and a MongoDB console.

Another great thing about tmux is that you can create multiple sessions within the same terminal window, and move between them, something like alt-tabbing between terminal windows, except it is much faster and with less visual distraction. An added bonus is that tmux is able to subdivide the visible portion of your terminal window into parts, so you can have multiple virtual consoles, all visible within one window. Very useful if you have lots of screen estate at your command, so that you can code in vim in one, access a MySQL console in another, and doing a sass --watch in yet another, for example. All the information you need, everything visible in the same window, for optimal productivity.

Continue reading tmux – an awesome little tool