Oct 11, 2010

Char search in Emacs as in Vim

Vladimir Sidorenko
Vladimir Sidorenko

In VIM there is a command for char search: f. After first use it can be repeated with ;. I like to navigate in line with it. You see that you need to go to bracket in a middle of a line - you press f( and one-two ; and you are there. There's no such command in Emacs, so I had to write my own. I've managed even to implement repetition with ;.

(setq last-search-forward-char nil)

(defun search-forward-char-continue ()
(if (and last-search-forward-char (or (eq (symbol-function last-command) (symbol-function 'search-forward-char))
(eq last-command this-command)))
(search-forward-char last-search-forward-char)
(insert ";")
(setq last-search-forward-char nil))))

(global-set-key (kbd "M-s") 'search-forward-char)
(global-set-key (kbd ";") 'search-forward-char-continue)

Key word here is last-command. Using the same principle other commands also can be assigned to same key.

More thoughts

Jan 28, 2017Technology
Creating a site preview like in slack (using aiohttp)

In this article we will write a small library for pulling metadata and creating a preview for a site just like Slack does.

Igor Tokarev
Igor Tokarev
Feb 28, 2017Technology
How to write an API in Django

There is such a term as Remote Procedure Call (RPC). In other words, by using this technology, programs can call functions on remote computers. There are many ways to implement RPC.

Vladimir Kalyuzhny
Vladimir Kalyuzhny
Oct 03, 2016Technology
How to include JQuery plugins in Angular 2 running via webpack

Learn more about how to include jquery plugins in angular 2 running via webpack. Our tutorial is perfect for Angular beginners.

Anton Lysenkov
Anton Lysenkov
Feb 18, 2010Technology
User profiles with inheritance in Django

Usually users' profiles are stored in single model. When there are multiple user types, separation is made by some field like user_type.Situation is a little more complicated when different data is needed for each user type.In this article I'll describe how I solve this task.

Vladimir Sidorenko
Vladimir Sidorenko