Vi and Emacs Without the Religion

Chris Patti over at Blind Not Dumb has gathered his courage and written a piece on vi versus Emacs. He approaches the subject, as the title suggests, without the usual religious fervor.

His take, which is hard to argue with, is that the best editor depends on what you are trying to do. If you want to edit text as quickly and efficiently as possible then vi/Vim is probably the editor for you. Be aware, though, that Vim is an editor not an IDE. Patti says that efforts to bolt on IDE-like features rarely end well. Either the extension doesn’t work well or it destabilizes Vim.

Emacs, on the other hand, is more of a programming environment that is highly optimized for dealing with text. That means that you can not only edit but do other other—usually but not always—text oriented tasks in the same environment. That gives rise to the familiar—to Emacsers—tendency to move everything possible inside Emacs.

The other advantage of Emacs is that you can customize it to operate in almost any conceivable way. Vim, of course, is also customizable but not nearly to the same extent.

Patti’s post is a balanced recounting of the benefits of each editor and may help n00bs trying to decide which one to use to pick the editor best suited for them. I’d bet that almost every Emacs/vi user knows and have used both. Many people start with one and switch to the other for some reason. From my point of view, I love using Emacs because I have adjusted it to enable a nearly frictionless workflow. Still, there are times when only vi/Vim is available so I’m glad to know both.

Posted in General | Tagged , | Leave a comment

Literate Programming with Org Mode

Frédérick Giasson, whom I’ve mentioned before, has a nice post on setting up Org mode for literate programming. Giasson’s post is mostly concerned with using literate programming to write Clojure but almost all of his setup is usable for other languages.

It’s a testament to the power of Org mode that very little has to be changed from the default settings to have a first class environment. Most of the significant changes that Giasson made involved setting up the environment for Clojure.

One non-trivial change he made for Org was to tangle the code automatically when the file is saved. That keeps the code file up-to-date with the Org source file. To make sure his buffers stay up to date, he calls global-auto-revert-mode so that when the code file is updated, any open buffers for the file are reloaded.

If you’re interested in trying out literate programming in an easy way, give Giasson’s post a read to see how little effort is required.

Posted in General | Tagged , | 1 Comment

Swiper

For some reason I had it in my mind that swiper depended on Lispy, or Spacemacs, or some other Vim-derived Emacs mode so I never really looked at it. Then I read Mike Zamansky’s post on swiper and had my eyes were opened. At a minimum, swiper is a much improved replacement for Emacs’s incremental search. You can take a look at Zamansky’s post to see how it improves on the default incremental search behavior1, but the TL;DR is that you get a sort of simplified regex search with all the candidates shown in the minibuffer. You can navigate this list with the usual 【Ctrl+n】 and 【Ctrl+p】 and then select the match you want.

It turns out, though, that once you have the underlying ivy mode installed everything gets better. You can get rid of ido-mode and smex and let ivy take care of the things they do. All the things you loved about ido-mode are done better with ivy. There’s a very nice manual to explains everything ivy2 can do

Watch Zamansky’s video on swiper—and the rest of his videos if you haven’t already—to see why this is a worthwhile upgrade. I’m still cautiously feeling my way with swiper and have started small. Here’s my current configuration:

(use-package swiper
  :ensure t
  :config
  (ivy-mode 1)
  (setq ivy-use-virtual-buffers t)
  (global-set-key "\C-s" 'swiper)
  (global-set-key (kbd "C-c C-r") 'ivy-resume)
  (global-set-key (kbd "M-x") 'counsel-M-x)
  (global-set-key (kbd "C-x C-f") 'counsel-find-file))

As you can see, I’m using it for find-file and execute-extended-command as well as isearch. Again, I’m starting cautiously but so far I think it’s a definite win.

Footnotes:

1

One small annoyance is that there’s a slight delay (a small fraction of a second) before the point moves to place selected. That may because the screen isn’t scrolled until you choose a match.

2

Ivy is the library that does much of the heavy lifting for swiper.

Posted in General | Tagged | 4 Comments

Repeat Last Complex Command

Xah Lee has a very useful post on the repeat complex command command. A complex command is one that uses the minibuffer. That’s different from the repeat command that is usually bound to 【Ctrl+x z】.

What happens is that the Elisp for the command is placed in the minibuffer and you can edit it before repeating the command. That’s nice if, say, you made a mistake on a regexp and want to fix it and retry the command. Oddly, I knew about only the repeat command but not the repeat-complex-command version so I’m was glad to see Lee’s post. Take a look at his post for the details.

The repeat-complex-command command is bound to a terrible key sequence so if you find yourself using it a lot you’ll probably want to rebind it to something convenient.

Posted in General | Tagged | 3 Comments

Stop Rule 41

The changes to Rule 41 approved by the US Supreme Court are the latest example of dangerous overreach on the part of law enforcement. If you don’t think the FBI should be allowed to break into your computer with only the flimsiest of safeguards, you should oppose these changes. At this point, only congress can block the changes from going into effect.

Click on the image to see what you can do

rule-41-banner4.png

Posted in General | Tagged | Leave a comment

Using Org Tables in Source Blocks

Andreas Gerler has a nice post that shows how to access individual table columns in a source block. If you don’t do this sort of thing frequently, it’s easy to forget the details. If you occasionally need this capability or think you might, bookmark this post so you have an easy way to reacquaint yourself with the procedure.

I haven’t written about using Org source blocks for a long time but they are tremendously powerful. If, for example, you’re writing up a lab report for a class, this is a wonderful way to put your data and exact calculations in the same file and then export the parts you want to turn in to a nicely formatted PDF file.

Does that sound familiar? It should. It’s just reproducible research writ small. If you’re out of school and producing reports or writing up results, the process is just as useful. I use this type of thing all the time in my day to day work and consider it one of the great things about Org mode and Emacs. If you want to see an another example of this sort of thing, I wrote about it here.

Posted in General | Tagged , | 1 Comment

Emacs Videos for N00bs

In yesterday’s post I wrote about Rainer König’s introductory videos on Org mode. Today, I want to continue that theme with a set of introductory videos for Emacs itself.

Mike Zamansky over at C’est la Z is producing a series of Emacs videos for n00bs. As of this writing Zamansky has 5 videos but he has others in the pipeline. Like König’s Org tutorials, they are mostly less than 10 minutes each so they are easy to watch. If you start with Video 11, the videos will play in sequence automatically but it’s worthwhile clicking on each video section because that will take you to a page with the video, associated notes, and code mentioned in the video.

So far, he has covered

  • Setting up the package manager
  • Intro to Org Mode
  • How to think about Emacs
  • Buffers
  • Windows

and is promising a video on effective navigation next.

Zamansky approaches the subject on how he uses Emacs so he introduces packages that he’s found useful as he goes along. At each step he adds the package and it’s configuration to his init.el file so you can see how to set it up. That code is also in the individual Video pages so you don’t have to worry about writing it down.

It’s an enjoyable series and should be especially useful for those just learning Emacs. Recommended.

Footnotes:

1

The video in the Introduction section is by someone else and not part of the series.

Posted in General | Tagged | 1 Comment

Org Tutorial Videos

Rainer König is producing a series of video tutorials on Org mode. Each video is typically short—less than 10 minutes—and addresses a specific aspect of Org. If you’re looking for an easy introduction to Org mode, this is what you want.

So far there are 8 videos1 but more are being added continually. There’s a convenient “Play all” button that will play all the videos in order. The 8 videos are just under 57 minutes so you’ll need to schedule some time but they’re easy to watch and you can always watch them piecemeal during coffee breaks or other spare time.

Because each video focuses on a specific target, König is able to cover that topic in reasonable depth. As usual with these introductory tutorials, I was still able to learn something new. König’s explanation of follow mode helped me understand the point of the functionality.

If you’re an Org mode user or you’re interested in learning about it, these videos are worth your time. They’re an easy way to learn the basics or review what you already know. Highly recommended.

Footnotes:

1

Since I wrote this on Thursday, König has added two more videos for a total of 10. The total running time is up to 77:15. It’s probably a good idea to subscribe to the videos so that you’ll be notified as he adds new ones.

Posted in General | Tagged , | Leave a comment

Copying Formatted Org Text to Other Apps

John Kitchin, who does a lot—most?—of his writing in Org mode sometimes wants to copy and paste Org text into other applications such as Word or the mail app. He wants more than just doing a verbatim copy, he wants the text to keep its formatting. Thus he wants links to appear as links instead of the Org markup for links, italics to appear as italics instead of text between slashes, and so on.

He noticed that this is what happens when you copy from, say, the browser, but not when you copy from Org. The answer, as this video explains, is to first convert the text to rich text format and then copy it to the clip board. After that, it can be pasted into the appropriate app.

Kitchin presents a bit of Elisp to take care of this on the Mac platform but it’s easy to see how you can adapt it to use tools appropriate to whatever platform you’re using. If you’re unfortunate enough to sometimes need to paste Org data into Word, this is just what you need. It’s easy to set up and pretty much seamless—other than assigning a key sequence to the code—to use.

Posted in General | Tagged , | Leave a comment

Keeping a Logbook or Journal

I ended yesterday’s post by noting that if you maintain a daily journal or log of your activities, you can get a timesheet for free. But what if you aren’t maintaining a log or journal? This

tweet inspired me to write about my journal, what’s in it, and how I maintain it. You won’t be surprised to learn that it’s all Org based.

I’ve always maintained a log book in which I kept track of what I was doing and ideas or notes that I might want to remember later. I’ve always thought of it as a sort of Lab Notebook. Before Org, I kept everything in a quad ruled, bound computation book. That’s a good solution but Org mode is much better.

Org capture makes it easy to make entries that are automatically filed according to day. The file is tree structured as1

* Year
** Month
*** Day
**** {time-stamped entries}

but the Org agenda search commands make it easy to jump to a particular date if I need to.

By far, the most important aspect of the journal is the tags. For example, every time I publish a blog entry it gets logged in my journal with a tag of blog. That makes it easy to find published blog posts, especially since each entry contains a link to the metadata for the post.

The tags make it possible to keep unrelated subject matter in the same file. For instance, I used to have a separate log file that I used to record events with other people that I might need to recall. A typical example is dealing with an account problem for some service. I can record the time and date of the call, who I talked to, and what the resolution of the problem was. Now I just add those entries to my journal with a tag of LOG. If the call was with my ISP, I add a tag of isp and then I can search the relevant entries by looking for entries with the tags LOG and isp.

Although I keep data in files other than my journal, I try to put as much as possible in journal.org. That includes pretty much everything I do during the day and even what restaurant I have dinner at if I eat out. Using a single file makes it easy to search for items or to make large edits on the file2. If you aren’t using a journal yet, I’d start with a single file until you discover that you need more. Once you get used to keeping the log, it will become second nature and you won’t have to think about it. And you’ll get a timesheet for free.

Footnotes:

1

I use the org-capture template

("j" "Journal" entry (file+datetree "~/org/journal.org")
         "* %<%R: >%? %^g\n%t")

to make entries. That takes care of making the entry and querying me for a tag or tags. The %<%R: > records the time as HH:MM.

2

A typical example is fixing tags. Sometimes I’ll accidentally use two nearly identical tags for the same event type and end up with several instances of each. It’s easy to fix that by doing a query-replace on the entire journal file.

Posted in General | Tagged , | Leave a comment