Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IntelliJ Edit & Shortcut demo
package okio
/**
* Tools ->
* Create Command-line Launcher
* IntelliJ can diff.
* Alt+F1 -> Select in...
*/
class EditingDemo(private val log: (String) -> Unit) {
/**
* Action Search
* Cmd+Shift+A
*/
/**
* Smart-Join
* Ctrl+Shift+J
*/
fun gimmeOneString(): String {
return "A, B, C, D, E, "
}
/**
* Completion: Enter versus Tab
*/
fun completion(first: String, second: String): Boolean {
return first.contains(second)
}
/**
* MultiCursor
*
* Select Next: Ctrl-G
* Skip Next: Cmd+G
*
* Option+Option+cursor
*/
fun doMagic() {
log("andreevici@squareup.com")
log("cui@squareup.com")
log("erb@squareup.com")
log("galligan@squareup.com")
log("mosley@squareup.com")
log("narayan@squareup.com")
log("precious@squareup.com")
log("rodriguez@squareup.com")
log("sherratt@squareup.com")
// Not this one.
// User Benoît Quenaudon
log("carranca@squareup.com")
log("tran@squareup.com")
log("stPierre@squareup.com")
}
/**
* Navigation
* Cmd+F12 for methods and fields.
*/
/**
* Bookmarks
* F3 to bookmark
* Cmd+F3 to access bookmarks
*
* Ctrl+Shift+<number> to assign a number
* Ctrl+<number> to go to the bookmark
*/
/**
* Scope Selection
* Alt+Up / Alt+Down
*
* Method Extraction
* Cmd+Option+M
*/
fun splitIntegers(limit: Int, evens: MutableList<Int>, odds: MutableList<Int>) {
var mod = 0
extractEven(limit, mod, evens)
mod = 1
for (i in 0 until limit) {
if (i % 2 == mod) {
odds.add(i)
}
}
}
private fun extractEven(
limit: Int,
mod: Int,
evens: MutableList<Int>
) {
for (i in 0 until limit) {
if (i % 2 == mod) {
evens.add(i)
}
}
}
/**
* Postfix templates
*/
fun postfix() {
for (i in listOf(0, 1, 42, 99)) {
}
}
/**
* Logic refactoring
*/
fun logWhenSurprise(a: Boolean, b: Boolean, c: Boolean, d: Boolean) {
if (!(!b && !a || !c && !d)) {
log("surprise")
}
}
/**
* Scope Completion to Type
* Ctrl+Space vs Ctrl+Shift+Space
*/
fun getArrayList(): ArrayList<*> {
TODO()
}
/**
* Local History
* Cmd+Shift+A > Show History
*/
/**
* Dope Shortcuts
*
* Last Editing Navigation: Cmd+Shift+delete
*
* Recently Opened Files: Cmd+E
*
* Next Error, Warning: F2
*
* Presentation Mode: Cmd+Shift+A > Presentation Mode
*
* Highlight Usage in File: Cmd+Shift+F7 > Cmd+G
*
* Line Movement: Option+Shift+Up/Down
*
* Lookup:
* File: Cmd+Shift+O(pen)
* Class: Cmd+O(pen)
* Action: Cmd+Shift+A(ction)
* Everything: Shift+Shift
*
* Plugin: Key Promoter X https://plugins.jetbrains.com/plugin/9792-key-promoter-x
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment