Emacs is a very famous and popular advanced text editor in the Linux / UNIX.
It’s a legacy technology, but it’s still being updated, making it a coding tool that goes beyond text editors.
We describe the installation and initial setup method of Emacs (Linux / Windows).
Sponsored Links
Emacs installation and initial setup
Linux(Ubuntu)
- Enter the following command with root authority, download and install.
- Below is an example on Ubuntu. Use “yum” on RHEL and CentOS.
# apt update
# apt-get install emacs
# exit
- Confirm startup as installation is complete.
- Enter the following command.
$ emacs &
- If Emacs starts as below, there is no problem.
- Close Emacs once.
- Create the init.el file, which is the Emacs configuration file, under the following directory.
- ~/.emacs.d/
- If the target directory does not exist, create a new one with the “mkdir” command.
- The setting example of init.el is as follows, modify it as you like.
- Create an init.el file by copying the contents.
;;
;; Hide splash at start
;;
(setq inhibit-startup-message t)
;;
;; Delete the character string in the * scratch * buffer immediately after startup
;;
(setq initial-scratch-message nil)
;;
;; Do not create a backup file
;; Do not create an auto save file
;;
;(setq make-backup-files nil)
;(setq auto-save-default nil)
;;
;; Backup destination
;;
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup"))
backup-directory-alist))
(setq auto-save-file-name-transforms
`((".*", (expand-file-name "~/.emacs.d/backup/") t)))
;;
;; thema
;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes (quote (manoj-dark))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;
;; Frame position setting
;;
(setq initial-frame-alist
(append
'((top . 22) ; Y position of frame
(left . 80) ; X position of frame
(width . 140) ; Frame width
(height . 50) ; Frame height
)
initial-frame-alist))
;; Display the number of characters in the frame
(column-number-mode t)
;; Show full file path in title bar
(setq frame-title-format "%f")
;; Set the indent offset to 2
(setq-default c-basic-offset 2)
;; Use spaces for tabs
(setq-default indent-tabs-mode nil)
;; Set default tab width to 2
(setq-default tab-width 2)
;; Visualize spaces, tabs
(global-whitespace-mode 1)
;; Show line number
(global-linum-mode t)
;; Show column number
(column-number-mode t)
;; Set the transparency of the frame
(set-frame-parameter (selected-frame) 'alpha '(0.90))
;; Disable automatic indentation
(electric-indent-mode 0)
;; Enter the TAB code with the "TAB" key
(setq tab-always-indent nil)
(setq c-tab-always-indent nil)
- Start Emacs again with the following command.
$ emacs &
- Unlike before, when Emacs like the one below starts, you can see that the settings are reflected.
Windows
Emacs is now also available for Windows.
- Access the official page.
- Click the link to the download site on the page (also possible from below).
- Click on the latest version of the directory.
- e.g. emacs-XX/
- Click on the latest x86_64 version of the zip file.
- e.g. emacs-XX.X-x86_64.zip
- Basically, the installation is completed by unzipping the zip file. Therefore, unzip the file and place it wherever you like.
- e.g. Create a “C:\Program Files\Emacs” directory. Place the unzipped directory, emacs-XX.X-x86_64, under it.
- Confirm startup as installation is complete.
- Double-click “bin\runemacs.exe” in the unzipped directory as the startup file. If Emacs starts as below, there is no problem.
- e.g. C:\Program Files\Emacs\emacs-27.1-x86_64\bin\runemacs.exe
- Double-click “bin\runemacs.exe” in the unzipped directory as the startup file. If Emacs starts as below, there is no problem.
- Close Emacs once.
- Create a startup file shortcut on your desktop or start menu if needed.
- Create the “init.el file”, which is the Emacs configuration file, under the following directory.
- If there is no target directory, create a new one.
- C:\Users\*User Name*\AppData\Roaming\.emacs.d\
- Place the “init.el” file under this.
- C:\Users\*User Name*\AppData\Roaming\.emacs.d\
- If there is no target directory, create a new one.
- The setting example of init.el is as follows, modify it as you like.
;;
;; Hide splash at start
;;
(setq inhibit-startup-message t)
;;
;; Delete the character string in the * scratch * buffer immediately after startup
;;
(setq initial-scratch-message nil)
;;
;; Do not create a backup file
;; Do not create an auto save file
;;
;(setq make-backup-files nil)
;(setq auto-save-default nil)
;;
;; Backup destination
;;
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup"))
backup-directory-alist))
(setq auto-save-file-name-transforms
`((".*", (expand-file-name "~/.emacs.d/backup/") t)))
;;
;; thema
;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes (quote (manoj-dark))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;
;; Frame position setting
;;
(setq initial-frame-alist
(append
'((top . 22) ; Y position of frame
(left . 80) ; X position of frame
(width . 140) ; Frame width
(height . 50) ; Frame height
)
initial-frame-alist))
;; Display the number of characters in the frame
(column-number-mode t)
;; Show full file path in title bar
(setq frame-title-format "%f")
;; Set the indent offset to 2
(setq-default c-basic-offset 2)
;; Use spaces for tabs
(setq-default indent-tabs-mode nil)
;; Set default tab width to 2
(setq-default tab-width 2)
;; Visualize spaces, tabs
(global-whitespace-mode 1)
;; Show line number
(global-linum-mode t)
;; Show column number
(column-number-mode t)
;; Set the transparency of the frame
(set-frame-parameter (selected-frame) 'alpha '(0.90))
;; Disable automatic indentation
(electric-indent-mode 0)
;; Enter the TAB code with the "TAB" key
(setq tab-always-indent nil)
(setq c-tab-always-indent nil)
- Double-click below to start again.
- e.g. C:\Program Files\Emacs\emacs-27.1-x86_64\bin\runemacs.exe
- Unlike before, when Emacs like the one below starts, you can see that the settings are reflected.
Sponsored Links