Back
Oct 11, 2010

Char search in Emacs as in Vim

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 ()
(interactive)
(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)
(progn
(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

May 18, 2017Technology
Angular2: Development Tips and Trick

In this article we'll discuss some tricks you can use with Angular to make routing cleaner and improve SEO of your application.

Alexandr Selyanov
Feb 18, 2010Technology
Business logic in models

In my recent project there was a lot of data business logic, so I had to organize this code somehow. In this article I'll describe a few hints on how to it.

Vladimir Sidorenko
Nov 6, 2021Technology
5 Best Practices of RESTful API Design to Keep Your Users Happy

Learn about RESTful API design best practices with helpful developer tips

Vladimir Sidorenko
Jun 25, 2011Technology
Ajax blocks in Django

Quite often we have to write paginated or filtered blocks of information on page. I created a decorator that would automate this process.

Vladimir Sidorenko
Mar 4, 2011Technology
Css sprite generation

I've created this small sprite to create css sprites. It glues images from directory directory into single file and generates corresponding css.

Vladimir Sidorenko
Feb 28, 2010Technology
Composing multiple views in Django

In UNIX way, each view should solve single task. This is good idea, but sometimes we need to mix logic of different views on same page. Filter, sort, paginate, or, for example, add comment on product page. In this article I'll show how we can mix such multiple views.

Vladimir Sidorenko