1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2024-11-24 15:42:44 +01:00
IntelliJ platform plugin to quickly jump in the editor. https://plugins.jetbrains.com/plugin/7086-acejump
Go to file
chylex 04c1519261
Optimize screen visibility checks during search
When 'Search whole file' is disabled, search results are tested for visibility on the screen. There is already an optimization that only checks results on visible lines, but the number of offset-to-XY conversions still scales linearly with the number of results, which can be very large in files with long lines.

A simple observation is that every line has a first and last offset that is visible on the screen (which may be different for each line due to proportional fonts).

This commit caches the visible offset range for every line involved in one search query, so testing visibility of a search result becomes a check if its offset is inside its line's visible offset range. Finding the visible offset range requires two XY-to-offset conversions per line, so the total number of conversions is bounded by the number of lines that can fit on the screen.

The worst case for this optimization is when every line has exactly one search result; before, this would lead to one offset-to-XY conversion per line, whereas now it leads to two XY-to-offset conversions per line. However, the maximum number of conversions is twice the number of visible lines, which will generally be very small.
2024-09-05 01:48:30 +02:00
.github/ISSUE_TEMPLATE fixes #408 2022-06-28 17:53:44 -07:00
gradle update to intellij gradle plugin v2 2024-08-02 15:11:49 -04:00
src Optimize screen visibility checks during search 2024-09-05 01:48:30 +02:00
.editorconfig Major AceJump refactoring! 2021-03-29 02:11:06 +02:00
.gitattributes Major AceJump refactoring! 2021-03-29 02:11:06 +02:00
.gitignore move project settings into build script 2018-10-13 21:52:58 -04:00
build.gradle.kts moved to gradle/libs.versions.toml 2024-08-02 15:47:33 -04:00
CHANGES.md build against platform 2024.1, #457 2024-04-06 16:43:35 -04:00
gradle.properties Do not bundle kotlin stdlib 2023-10-27 20:42:45 +02:00
gradlew bump gradlew version 2020-11-27 01:03:15 -05:00
gradlew.bat bump gradlew version 2020-11-27 01:03:15 -05:00
LICENSE fixes #240 2018-10-13 13:12:51 -04:00
logo.png add logo & icon 2020-08-17 21:02:39 +02:00
README.md remove obsolete warning 2024-04-23 21:02:02 -04:00
settings.gradle.kts add project name 2018-06-02 18:31:18 -04:00

AceJumpLogo

AceJump is a plugin for the IntelliJ Platform that lets you jump to any symbol in the editor with just a few keystrokes. Press the keyboard shortcut for AceAction (Ctrl+; by default) to activate AceJump. Type any string in the editor, followed by one of the illustrated tags, to jump its position:

Press the AceJump shortcut a second time to activate Declaration Mode, which is equivalent to the Navigate To action in the IDE. Press the AceJump shortcut three times before completing a tag to activate Target Mode. Once Target Mode is activated, jumping to a tag will select an entire word. Target Mode can also be activated directly by pressing the shortcut for AceTargetAction (Ctrl+Alt+; by default).

Press the AceJump shortcut for Line Mode(Ctrl+Shift+; by default), to target the beginning, first non-whitespace, and last character of every line in the editor). Then jump to one by completing the tag.

Press the AceJump shortcut, followed by to target the last, to target the first, or , to target the first non-whitespace characters of every line in the editor.

Tips

  • Press Tab when searching to jump to the next group of matches in the editor.

  • If you make a mistake searching, just press Backspace to restart from scratch.

  • If no matches can be found on-screen, AceJump will scroll to the next match it can find.

  • Note that search is smart case sensitive, however tag selection is not case sensitive.

  • Holding down Shift when typing the last tag character will select all text from the current cursor position to that destination.

  • Pressing Enter or Shift+Enter during a search will cycle through tagged results on screen.

    • To select a location and continue editing, just press Esc.

    • To use this feature with IdeaVim, you must be in Vim's Insert Mode (to be fixed at a later point).

  • Keep typing! AceJump will accept multiple sequential characters before tag selection.

  • Press the AceJump shortcut multiple times to cycle between modes.

  • Word Mode action that will tag all visible words as soon as it is activated.

  • Declaration Mode will jump to a token's declaration, if it exists.

  • To rebind any keyboard shortcuts visit Settings | Keymap | 🔍 "AceJump"

Installing

AceJump can be installed directly from the IDE, via Settings | Plugins | Browse Repositories... | 🔍 "AceJump".

Configuring

IdeaVim users can choose to activate AceJump with a single keystroke (f, F and g are arbitrary) by running:

echo -e '

" Press `f` to activate AceJump
map f <Action>(AceAction)
" Press `F` to activate Target Mode
map F <Action>(AceTargetAction)
" Press `g` to activate Line Mode
map g <Action>(AceLineAction)

' >> ~/.ideavimrc

To customize AceJump's behavior further with additional actions, see the <action> tags in plugin.xml. The following example shows how to activate AceJump before or after the caret.

" Press `S` in normal mode to activate AceJump mode before the caret
nmap S <Action>(AceBackwardAction)

" Press `s` in normal mode to activate AceJump mode after the caret
nmap s <Action>(AceForwardAction)

To change the default keyboard shortcuts, open File | Settings | Keymap | 🔍 "AceJump" | AceJump | Enter⏎.

Keymap

Building

Prerequisites: JDK 8 or higher.

To build AceJump, clone and run the Gradle task buildPlugin like so:

  • git clone https://github.com/acejump/AceJump && cd AceJump
  • For Linux and Mac OS: ./gradlew buildPlugin
  • For Windows: gradlew.bat buildPlugin

The build artifact will be placed in build/distributions/.

Miscellaneous: AceJump is built using Gradle with the Gradle Kotlin DSL and the gradle-intellij-plugin.

Extending

AceJump can be used by other IntelliJ Platform plugins. To do so, add the following snippet to your build.gradle.kts file:

intellij {
  plugins.set("AceJump:<LATEST_VERSION>")
}

Callers who pass an instance of Editor into SessionManager.start(editor) will receive a Session instance in return. Sessions are disposed after use.

To use AceJump externally, please see the following example:

import org.acejump.session.SessionManager
import org.acejump.session.AceJumpListener
import org.acejump.boundaries.StandardBoundaries.*
import org.acejump.search.Pattern.*

val aceJumpSession = SessionManager.start(editorInstance)

aceJumpSession.addAceJumpListener(object: AceJumpListener {
  override fun finished() {
    // ...
  }
})

// Sessions provide these endpoints for external consumers:

/*1.*/ aceJumpSession.markResults(sortedSetOf(/*...*/)) // Pass a set of offsets
/*2.*/ aceJumpSession.startRegexSearch("[aeiou]+", WHOLE_FILE) // Search for regex
/*3.*/ aceJumpSession.startRegexSearch(ALL_WORDS, VISIBLE_ON_SCREEN) // Search for Pattern

Custom boundaries for search (i.e. current line before caret etc.) can also be defined using the Boundaries interface.

Contributing

AceJump is supported by community members like you. Contributions are highly welcome!

If you would like to contribute, here are a few of the ways you can help improve AceJump:

To start IntelliJ IDEA CE with AceJump installed, run ./gradlew runIde -PluginDev [-x test].

To just run the tests, execute ./gradlew test - this is usually much faster than starting an IDE.

For documentation on plugin development, see the IntelliJ Platform SDK.

Release notes

Please see here for a detailed list of changes.

Comparison

AceJump is inspired by prior work, but adds several improvements, including:

  • Ergonomic tagging: Tries to minimize finger and eye travel on most common keyboards layouts and languages.
  • Full-text search: If a string is not visible on the screen, AceJump will scroll to the next occurrence.
  • Smart tag rendering: Tags will occupy nearby whitespace if available, rather than block adjacent text.
  • Target mode: Jump and select a full word in one rapid motion. (Ctrl+Alt+;)
  • Line Mode: Jump to the first, last, or first non-whitespace character of any line on-screen (Ctrl+Shift+;).
  • Word Mode: Jump to the first character of any visible word on-screen in two keystrokes or less.
  • Declaration Mode: Jump to the declaration of a token (if it is available) rather than the token itself.
  • Unicode support: Unicode search and selection, e.g. to search for "拼音", activate AceJump and type: py

The following plugins have a similar UI for navigating text and web browsing:

Source Code Download Application Actively Maintained Language
AceJump IntelliJ Platform ✔️ Kotlin
IdeaVim-EasyMotion IntelliJ Platform ✔️ Kotlin
KJump IntelliJ Platform ✔️ Kotlin
AceJump-Lite IntelliJ Platform Java
emacsIDEAs IntelliJ Platform Java
TraceJump Desktop Kotlin
ace-jump-mode emacs Emacs Lisp
avy emacs ✔️ Emacs Lisp
EasyMotion Vim Vimscript
eyeliner.nvim NeoVim ✔️ Lua
Hop NeoVim ✔️ Lua
leap.nvim NeoVim ✔️ Fennel
lightspeed.nvim NeoVim Fennel
Sublime EasyMotion Sublime Python
AceJump Sublime Python
Jumpy Atom ✔️ TypeScript
Jumpy2 Visual Studio Code ✔️ TypeScript
Find-Jump Visual Studio Code TypeScript
MetaGo Visual Studio Code ✔️ TypeScript
VSCodeVim Visual Studio Code ✔️ TypeScript
CodeAceJumper Visual Studio Code TypeScript
AceJump Visual Studio C#
EasyMotion Visual Studio C#
tmux-fingers tmux ✔️ Crystal
tmux-thumb tmux ✔️ Rust
tmux-jump tmux ✔️ Ruby
tmux-copycat tmux Shell
cVim Chrome JavaScript
SurfingKeys Chrome/Firefox/Edge ✔️ JavaScript
Vimium Chrome/Firefox/Edge ✔️ JavaScript
Vimium-C Chrome/Firefox/Edge ✔️ TypeScript
Vrome Chrome CoffeeScript
ViChrome Chrome CoffeeScript
VimFx Firefox ✔️ CoffeeScript
Vimperator Firefox JavaScript
Pentadactyl Firefox JavaScript
Vim Vixen Firefox 57+ ✔️ JavaScript
Tridactyl Firefox 57+ ✔️ TypeScript
Vimari Safari JavaScript
Jump To Link Obsidian ✔️ TypeScript

Acknowledgements

The following individuals have significantly improved AceJump through their contributions and feedback:

AceJump is made possible by users just like you! If you enjoy using AceJump, please consider Contributing.