General Editing

Auto Save

One of the most unexpected things for newcomers to IntelliJ is that you don't seem to have to save. Indeed, IntelliJ will automatically save either after a certain amount of time (15 sec of inactivity by default) or at certain critical points (when it loses focus, before you run something, etc). This is something that seems very strange to many people at first but most grow to love it. If not, you can disable it in Settings→Appearance & Behaviour→System Settings. If you make a change you'd like to revert, you can always use the Local History function.

Completion

As you're typing, Cursive will suggest autocompletions for the symbol you're currently typing. It will autocomplete symbols, keywords, namespaces and so forth. You'll be shown the parameters of functions and the namespaces that the symbols come from in the completion list. Pressing tab will choose the highlighted option (or the top option if none are selected) and replace the current symbol with it. Pressing enter will choose the highlighted option and insert its text directly, without removing the current symbol. Cursive will match the text you've typed anywhere in the completion text, it doesn't have to be at the start.

When you complete the name of a var using a namespace alias that isn't currently require'd, Cursive will automatically add a require to your ns form for you. Similarly, if Cursive sees an aliased var reference that it can't currently resolve it will prompt you with options to require it.

These will also do what you'd expect in the REPL too.

Class Completion

Similarly to the var completions, when you complete the name of a class that isn't currently imported, Cursive will import it for you. If Cursive sees you've typed the name of a class it doesn't recognise it will prompt you with options to import it.

These will also do what you'd expect in the REPL too.

Rename

Cursive also allows you to rename symbols using Shift+F6 (Refactor→Rename…). This will rename the symbol where it's defined as well as at all usage points.

This works across files too.

Implement and Override methods

When implementing Java interfaces or extending classes with proxy, Cursive can fill in stubs for the methods you need to create for a particular class. There are two options - Implement Methods and Override Methods, and they're both accessed from the Generate command (). In general, Implement will present a list of all the methods you need to implement for a particular class, generally interface methods and base class abstract methods. Then you can use Override to selectively override base class methods, either from the base class in the case of a proxy, or from Object. This functionality is currently supported for proxy, reify, defrecord and deftype.

Coming Soon: Implement functionality for protocols.

Optimize Imports

Cursive integrates with the Optimize Imports function in IntelliJ to update your ns form according to how you have it configured. The configuration is in the config pane at Settings | Editor | Code Style | Clojure | Namespaces. By default, it will make your namespaces look like the famous How to ns document, but it's possible to change this to a certain extent.

Currently, this feature doesn't handle reader conditionals well. It will work on cljc files as long as the ns declaration doesn't contain reader conditionals, but if it does contain them then Cursive won't touch it. This will be fixed in the future.

Cursive will now mark requires from ns forms as unused if they're not used anywhere in the code. Unused referred symbols and aliases will also be marked. All of this will also be automatically cleaned up by the Optimize Imports operation.

Since require is also side-effecting, sometimes namespaces are required for their side effects even if they're not used explicitly in the code (e.g. for loading multimethod implementations, specs and so on). clj-kondo has a convention that namespaces which have no modifiers (i.e. no :as or :refer) are treated as side-effecting requires and are not marked as unused. While this is a little magic for our liking, users are used to it by now so Cursive supports it by default. If you'd rather not have it do that you can disable it in the configuration for the "Unused require" inspection.

Create function from usage

Cursive can also create a function implementation stub from an example usage. This will work both within the same file, and in another namespace.


The REPL Structural Editing