What Your Programming Editor Should Be Able To Do.
And how I do these tasks in Emacs.
As a programmer, you spend 80% of your time in the editor. You need to master it if you want to boost your productivity. The artisan who doesn't care for their tools is no artisan at all.
This is an incomplete list of the things your editor should be able to do for you. Please help me make it better by suggesting functionality that you find indispensable in your editor.
I have tried to arrange it in decreasing order of importance. I consider all this functionality table stakes, but if you must prioritise then start from the top.
- Complete Anything (In Emacs: company, capf, eldoc)
- Jump to source and back (In Emacs: xref, via dumb-jump or eglot)
- Check your syntax as you type (In Emacs: flycheck, flymake)
- Understand and manipulate your project structure (In Emacs: project.el)
- Use Git from the editor (In Emacs: magit)
- Edit code as a structured entity (In Emacs: paredit)
- Jump to important points in your code quickly (In Emacs: imenu and avy, helm)
- Understand and refactor your programming language (In Emacs: eglot, cider, clj-refactor, clojure-lsp)
- Run your tests on-demand, and show you the results (In Emacs: cider-test)
- Debug your code using a powerful debugger (In Emacs: gud, cider-debug, dap-mode)
- Support templates and expansion (In Emacs: yasnippet, org-capture)
- Support automating fast edits (In Emacs: kmacro-start-macro, multiple-cursors)
- Upcoming Experimental features
Complete Anything (In Emacs: company, capf, eldoc)
Your editor should be able to show you completions for anything you are currently typing. This list includes, but is not restricted to:
- Completion of functions, variables, types, namespaces, classes, plain-text.
- Completion of arguments, with doc-strings
Note: eldoc
is an Emacs built-in
Jump to source and back (In Emacs: xref, via dumb-jump or eglot)
Your editor should be able to jump to the definition of something on demand. This can be symbol at point (meaning word under the cursor) or can be anything I choose to enter.
- M-. : Jump to the source of something
- M-, : Jump back from the source of something
Note: xref
is the built-in Emacs jump mechanism, eglot
is the built-in Emacs LSP client
Check your syntax as you type (In Emacs: flycheck, flymake)
Your editor must be able to integrate with a linter program. As you are typing code, it should be able to point out all the problems in your code without getting in your way or slowing you down.
Note: flymake
is the built-in Emacs mechanism for integrating checkers and linters
flycheck
key-bindings:
- C-c ! l : List all errors
- C-c ! n : Go to the next error
- C-c ! p : Go to the previous error
- M-g M-n : Go to the next error
- M-g M-p : Go to the previous error
Understand and manipulate your project structure (In Emacs: project.el)
Your editor should have an understanding of the current project you are working in, as a whole. You should be able to quickly search for occurrences of certain words / phrases / symbols across the project. You should be able to pull up any file you wish in the project quickly, without needing to know exactly how the project is structured on disk
Note: project.el
is the built-in Emacs project manager
project.el
key-bindings:
- C-x p p : Switch to a project on disk
- C-x p f : Find a file in the current project
- C-x p G : Search for something in the current project
Use Git from the editor (In Emacs: magit)
Your editor should be able to give you the full power of your version control system in your editor. This includes, but is not limited to: creating new commits, listing changes made in a certain file(s), jumping to different versions of the code in the VCS.
magit
key-bindings:
- M-x magit-status : Access the magit-status buffer for your project.
- C-c C-c : Access the full set of possible actions in your buffer
- M-x magit-blame-addition : For each line of the current buffer, show the revision which it was added in
Edit code as a structured entity (In Emacs: paredit)
Your editor should be able to understand the semantics of your programming language. It should be able to recognise and move quickly between functions and expressions. It should be able to manipulate entire expressions in one go.
- C-a :
beginning-of-line
- C-e :
end-of-line
- M-a :
backward-sentence
- M-e :
forward-sentence
- C-M-f :
forward-sexp
- C-M-b :
backward-sexp
- C-M-a :
beginning-of-defun
- C-M-e :
end-of-defun
- M-m :
back-to-indentation
- C-) :
paredit-forward-slurp-sexp
- C-( :
paredit-backward-slurp-sexp
- C-} :
paredit-forward-barf-sexp
- C-{ :
paredit-backward-barf-sexp
Jump to important points in your code quickly (In Emacs: imenu and avy, helm)
Your editor should be able to jump to all the important points of your code in the least number of keystrokes (i.e. quickly). You should be able to quickly see all function names, type declarations, variable declarations in a given file and ideally in a given project as well. You should be able to jump to any word on the screen quickly.
Note: imenu
is a built-in Emacs feature.
My helm
and avy
key-bindings:
- C-x c i : Show all the function, type, variable declaration names and be able to jump to any of them with a few keystrokes
- C-x c b, C-c n : Cycle through all the "sessions" and resume any you wish. A session here is a search of any kind that you have done before: for a file name, symbol name, variable listing, bookmarks etc
- M-g SPC : Jump to a word on screen by typing the starting character
Understand and refactor your programming language (In Emacs: eglot, cider, clj-refactor, clojure-lsp)
Your editor should have a clear understanding of the code you are writing, and should be able to help you change it faster. This includes, but is not limited to:
Note: eglot
is the built-in LSP client for Emacs. cider
, clj-refactor
and clojure-lsp
are Emacs packages specific to the Clojure programming language.
- Refactoring support:
- Being able to rename symbols across the project
- Being able to suggest code clean up
- Being able to quickly import / clean-up dependencies
- Finding usages of code:
- Being able to find all the places where a certain function is being used
Run your tests on-demand, and show you the results (In Emacs: cider-test)
Your editor should be able to run the tests of your project, integrating with your test-runner. It should be able to run these tests on-demand, and show the results of running the tests. You should be able to re-run all the tests, or only the failed tests. This depends on the test-runner and not the editor, so check whether your test-runner is powerful enough.
cider-test
is provided by the cider
Emacs package for running Clojure project tests. Other languages have similar modes provided for their projects.
Debug your code using a powerful debugger (In Emacs: gud, cider-debug, dap-mode)
Your editor should integrate with and start a debugger on demand. At least the basics of debugging (set breakpoints, step-in, step-out, see local variables) should be supported.
Note: In Emacs, gud
is built-in and integrates with a variety of debuggers.
Support templates and expansion (In Emacs: yasnippet, org-capture)
Your editor should support creation and fast usage of templates (snippets) for common boiler-plate functionality. This speeds up development and documentation tremendously.
Support automating fast edits (In Emacs: kmacro-start-macro, multiple-cursors)
Your editor should be able to help you with one-off weird edits, eg: automatically numbering every new line with an incrementing counter.
Upcoming Experimental features
I am currently working on fine-tuning my editor experience to work best with LLMs and Code Assistants. The current state-of-the-art for this is the VSCode fork Cursor, and there is excellent work happening in this area.
Stay tuned!
Published On: Fri, 11 Nov 2016. Last Updated On: Sun, 04 Aug 2024.