---
title: "2 UNIX anti-patterns"
canonical: "/2016/12/16/2-unix-antipatterns/"
date: "2016-12-16"
author: "Alok Singh"
tags: []
---


Using visual mode in `vim` is often like using `cat` in UNIX:
unnecessary. If you're uncharitable, it indicates a lack of
understanding about the basic philosophy of each piece of software.

UNIX tools are designed to work on files and STDIN (standard input).
Which is why piping a file through `cat` into a utility like `grep` is
pointless since `grep` can work on files directly.

Say you want to search for the word "dog" in a file called "my\_file".
Instead of `cat my_file | grep "dog"`, you can just type
`grep "dog" my_file`.

Similarly, Vim has *operators*, which are designed to work on [*text
objects*](https://glts.github.io/2013/04/28/vim-normal-mode-grammar.html).
Which is why there's rarely a need to visually select text, unless it's
a very irregular region. For most use cases, like copying a paragraph,
you can just give the operator the text object directly.

For example, say you want to delete a paragraph. Rather than typing
`vap` (`v`isual `a`round `p`aragraph) and then `d` (`d`elete), you can
just type `dap`.

There are use cases for both "anti-patterns". In a long pipeline, typing
cat at the beginning can make it clearer to read, and selecting
irregular regions or desiring visual feedback on certain operations
benefits from visual mode.

But a lot of the time, there's no reason to use them.
