Beyond the Basics

Pistos edited this page Dec 6, 2012 · 16 revisions

This page lists and describes a few of the more advanced things you can do with Diakonos.

Opening Files

Fuzzy file find

By default fuzzy file finding is on. When you specify a file to open with Ctrl-O, you only have to type a few of the distinguishing characters of the file or path, and then select the file from the list of matches. For example, to open a filepath lib/application/module/filename.rb, you could just type mo/fil. Set the session directory (Alt-S D) to tell Diakonos where to do the fuzzy file finding from. Use the fuzzy_file_find.ignore configuration directive to filter out directories from the fuzzy file find.

Tab completion

If fuzzy file finding is not your thing, you can use tab completion to traverse down paths. The up and down arrow keys are also available for selecting a file from the presented list of directory contents. Press Enter to open the highlighted file. Press Ctrl-W to delete the right-most path component on the input line (i.e. travel up the path). Ctrl-K deletes the whole line so you can start over.

Open at a specific line

When opening files (whether when starting Diakonos, or with Ctrl-O), provide a line number by suffixing the filename with a colon and a number. e.g. some/file.rb:56 Diakonos can parse the stack trace output of some languages (such as Ruby and Python), so it is unnecessary to clean up stack trace lines: Simply double click a file with line number from a stack trace, then paste it to Diakonos. e.g. Diakonos understands lib/diakonos.rb:307:in.

Searching

Grep

Alt-G to grep the current buffer. Alt-Shift-G to grep all buffers at once. Ctrl-Alt-G to grep within a directory. When typing in the expression to grep for, matches are shown while you type. Use F6 and F5 to increase or decrease the amount of context shown around each match. Use the arrow keys to select a match and press Enter to jump to the selected match.

Search within selection

After selecting text, all find functions (including replace functions) restrict themselves to searching only within the selected area.

Search while searching

While typing in a search expression with a find function, Diakonos will jump to and highlight matches as you type. F3 and Shift-F3 also work while typing (before you press Enter to submit the search).

Regexp groups in replacement

Groups in search expressions (captured with parentheses) can be referred to in replacements using \1, \2, etc.

Selection

Select code blocks

Use Alt-space to select the block of code containing the current line (for non-empty lines). Press Alt-space more times to select increasingly outer code blocks.

Select words

Press Ctrl-space twice to select the current word. Press Ctrl-space more times to expand the selection to include more words.

Block selection

Alt-Shift-M B to switch to block (rectangular) selection. Alt-Shift-M N to return to normal selection.

Scripting

Process text with Ruby

Select some lines. Press F7, then enter any Ruby code that operates on a line variable. The Ruby code is executed on every line. Or: select some lines and press Alt-F7. The given Ruby code is executed on an Array containing the selected lines, represented by a lines variable.

Run anything

F2 to run a shell command and get the results in a new buffer. F8 to run a shell command and see the exit status (discard output). Shift-F2 to run arbitrary Ruby code.

Macros

Alt-M to start or stop macro recording. F4 to play back the last recorded macro.

Other

Delete to, from or within

Press Ctrl-D T and then type a character to delete from the cursor up to the next instance of that character. Press Ctrl-D F and then type a character to delete from the previous instance of that character up to the cursor. Press Ctrl-D I and then type a character to delete between the nearest instances of that character. If a bracket character is typed, Diakonos will delete between matching opposite brackets (e.g. between [ and ]).

Diff

To diff two sets of lines, copy the first set to the clipboard, then select the second set and press Alt-D. (Ctrl-W to close the diff buffer.)

Context line

Press Alt-Shift-C to toggle the context line on and off. The context line shows the outermost blocks surrounding the current line. This feature mostly obviates the need for code folding.

Back button

Press Ctrl-J to jump back to a previous location. Ctrl-L to jump forward.

Columnize

Select some lines, then press Alt-A to align source code into columns. Useful for prettifying multi-line hashes, arrays, assignment, etc.

Renumber buffers

Ctrl-B 1 to renumber the current buffer to buffer 1. Same idea for 2, 3, etc.

Close tags

Alt-C to close XML and HTML tags. This can be configured for any language.

Word completion

Type the beginning of a word, then press Alt-E to complete it using the words found in the current buffer.

Comment out, uncomment

Alt-Shift-3 (i.e. Alt-#) to comment out the current line or selection. Alt-Shift-2 (Alt-@) to uncomment.

Manual indentation

Use Alt-I and Alt-Shift-I to manually indent and unindent the current line or selection.