- Published on
How to setup Emacsclient
Setting up emacsclient
allows one to open and edit files in an already running Emacs instance, which is especially useful when working with multiple files or as part of a scripted workflow.
Ensure Emacs Server is Running:
Start Emacs if it's not already running.
In Emacs,start the server by evaluating
(server-start)
in the scratch buffer or by adding it to Emacs configuration (init.el
or.emacs
):(server-start)
Set the
EDITOR
Environment Variable:Add the following line to shell profile configuration file (e.g.,
~/.bashrc
,~/.zshrc
, etc.), which sets theEDITOR
environment variable toemacsclient
:export EDITOR="emacsclient -c"
Reload shell configuration to apply the changes (e.g.,
source ~/.bashrc
).
Alias for Simplicity (Optional):
alias ec="emacsclient -c"