I decided to write JSP (Java Server Pages) in Emacs, but there was no code formatting setting.
CentOS 6 GNU Emacs 23.1.1
STEP 1 Download the file from Download here. (I downloaded it from Github.)
STEP 2 Unzip the downloaded file using the ʻunzip` command or tool.
STEP 3 Create one directory in your home directory (wherever you like).
python
mkdir ~/load
This time I created a load
directory.
STEP 4
Put web-mode.el
in the unzipped file in ~ / load
.
STEP 5 Pass the path so that the previous file can be read.
emacs ~/.emacs
After opening .emacs, enter the following code. (At the same time, I also entered the rules for web-mode. This time I borrowed the settings of other people)
~/.emacs
;Pass through(You will be able to require.)
;Enter the path to the directory you created.
(add-to-list 'load-path "~/load")
; web-mode setting
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
; .For jsp Actually, I think this alone is fine.
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(defun my-web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-attr-indent-offset nil)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-sql-indent-offset 2)
(setq indent-tabs-mode nil)
(setq tab-width 2))
(add-hook 'web-mode-hook 'my-web-mode-hook)
STEP 6
There is no. the end.
Ctrl-c Ctrl-i
cleans the indent.
It seems that there are other shortcut keys.
This happened because the file couldn't be placed where the load-path
originally passed due to a permit problem. I'm not sure, but I couldn't use package-install
either.
If you make settings, you can exceed VScode ...? (I won't do it.)
-Official site -I investigated the environment for React (JSX) coding with Emacs -Web-mode setting for writing JSX in Emacs
Recommended Posts