Hack and / - Dr hjkl and Mr Hack
Without diving headfirst into an ancient Linux holy war, let me set the record straight. I am a card-carrying, home-row hugging, Esc-key hammering, vim user. If you love Emacs, JOE, ed, Kate, gedit or the magnifying-glass-and-magnet approach to text-file editing, that's fine, and I'm not here to judge. It's just that for me, once I got over the initial vi(m) learning curve, I started looking for other tools that take the same approach to key bindings. Specifically, I am talking about the h, j, k and l keys and how you can use them to move left, down, up and right, respectively, in a document. What I found was that most of my favorite tools either already had vi-style key bindings or there was a simple way to enable them. Some programs even offered advanced bindings that closely mimic vim in a number of ways. In this column, I highlight some programs that either have vi key bindings or can be made to have them with a few simple steps.
Before I start talking about specific programs, I probably should explain why navigation with hjkl is better than with the arrow keys. It's a dirty secret among vim users that many people just use the arrow keys and backspace to edit their documents. The main reason hjkl navigation is great is that all of those keys are on the home row. In case you never took formal typing, the home row is the asdfghkl row of keys on a qwerty keyboard. If you learn to touch type, you are taught to rest your fingers on this row by default. This means the hjkl keys are within easy reach, but every time you reach for the arrow keys you have to move your right hand off the home row. Now, if you aren't a touch typist, that isn't a big deal. But if you are, it is almost as disruptive as reaching for the mouse. Granted, I know it is awkward at first, but if you are a vim user and touch type at all, it's worth it to force yourself to use hjkl for navigation until it becomes second nature.
In case you are new to vi key bindings, here are some of the main keys that you'll find work similarly in other programs:
h — move left
j — move down
k — move up
l — move right
^ — move to the beginning of a line
$ — move to the end of a line
G — move to the bottom of the document
g — move to the top of the document (gg in vim)
w — move the cursor ahead one word
b — move the cursor behind one word
/ — enter search mode
n — go to the next search result
N — go to the previous search result
A number of standard command-line programs use vi-style navigation out of the box, and the first I want to mention is less. The less program allows you to page through a text file, and if you needed yet another reason to use less instead of more, use it because j and k will move down and up a document. In addition, you can type G to scroll to the very bottom of a document and g (gg in vim) to move to the very top. As with vim, you also can press / to type a search term, and press Enter, then press n and N to find the next and previous matches, respectively. Like with less, by default, you can scroll through man page output with the same keys.
Screen also can use vi key bindings to navigate through its copy mode. Screen is an amazing shell program that allows you to open multiple shell sessions and detach and re-attach to them. If you've started using screen after being used to a regular terminal session, you likely ran into the strange behavior screen exhibits when you press Shift and PgUp and PgDn (or use the scroll bar) to scroll up and down through the output. In screen, if you want to view output that has scrolled past the top of the terminal, simply press Ctrl-A Esc to enter copy mode. Within copy mode, now you can use the arrow keys (shame on you) or hjkl to scroll around the output. As with less, you also can use g and G to scroll to the top and bottom of the output. When you are done scrolling, simply press the q key to exit copy mode.
Even bash itself can be set so that you can navigate the command line in true vi style. In your bash shell, just type set -o vi. Now, keep in mind that once you enable this option, you will have to enter insert mode (press the i key) to insert text just like in vi. And, if you want to use h or l to move the cursor left or right, or w or b to move forward or back a word, you will have to press Esc to leave insert mode. For those of you who tried this and want to undo it, simply press i to enter insert mode, and then type set -o emacs.
Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- Designing Electronics with Linux
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Build a Skype Server for Your Home Phone System
- Validate an E-Mail Address with PHP, the Right Way
- A Topic for Discussion - Open Source Feature-Richness?
- Why Python?
- Tech Tip: Really Simple HTTP Server with Python
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




2 hours 9 min ago
2 hours 17 min ago
4 hours 32 min ago
7 hours 2 min ago
17 hours 4 min ago
21 hours 31 min ago
1 day 1 hour ago
1 day 1 hour ago
1 day 4 hours ago
1 day 4 hours ago