Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one quickly browse through lots of files in Emacs?

Tags:

emacs

dired

is there a way to quickly browse through lots of files in Emacs (24.3)? More specifically:

Let's assume an Emacs frame is split into two windows. Suppose focus is in the left window that has an open 'dired' buffer with lots of text files (or code). I would like to go up and down the list of files (e.g. with cursor keys), while at the same time the current file is shown in the right window. Even better the file is only viewed and closed once I move in the dired buffer to the next file. This would be very useful especially together with some 'omit' mode.

Can this be done in 'dired'? I also coudn't find this functionality in dired-x or in sunrise-commander. Is it possible?

The best candidates I tried already (and why they not solve the problem):

'v' which shows the current file, but also moves the attention

'C-o' which shows the current file, but after moving up or down, I have to press C-o again, also it generates lots of buffers

Thanks a lot for your help!

like image 591
Harmeling Avatar asked Nov 11 '13 13:11

Harmeling


1 Answers

A simple and generic (while not optimum) solution could be via the C-x () mechanism.

First open the two panes in Emacs, with - say - top one being dired.

  • Press o to open the first file in the 2nd pane.

Then you can start the repetition mechanism:

  • do C-x ( to start recording a macro
  • do C-x k and return to close the buffer
  • do o again to go back to dired
  • do down key to go to next file
  • do o to open next file in bottom pane
  • do C-x ) to end the macro

From that point (being in bottom pane, dired in top pane), doing a mere

  • C-x e (and then only e if there is no other operation in between)

will automatically

  • close bottom pane file, go to top pane, down to next file, open it in bottom pane

There is maybe a more specific way to do that, but knowing the macro mechanism is anyway very helpful in Emacs.

like image 198
Déjà vu Avatar answered Oct 24 '22 17:10

Déjà vu