[JAVA] I want to write JSP in Emacs more easily than the default.


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.) キャプチャ.PNG

STEP 2 Unzip the downloaded file using the ʻunzip` command or tool.

STEP 3 Create one directory in your home directory (wherever you like).


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)


;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.

in conclusion

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

I want to write JSP in Emacs more easily than the default.
I want to get the value in Ruby
I want to embed any TraceId in the log
Pointcut Expression I want to specify more than one
I want to set the conditions to be displayed in collection_check_boxes
(´-`) .. oO (I want to easily find the standard output "Hello".
I want to use the sanitize method other than View.
I want to transition to the same screen in the saved state
I want to simplify the conditional if-else statement in Java
I want to display the images under assets/images in the production environment
I want to remove the top margin in Grouped UITableView (swift)
[Java] I want to perform distinct with the key in the object
I want to control the default error message of Spring Boot
I want to change the value of Attribute in Selenium of Ruby
I think it's okay to write joins etc. in the scope
[Android] I want to get the listener from the button in ListView
I want to write a nice build.gradle
I want to write a unit test!
I want to use @Autowired in Servlet
[Ruby] I want to output only the odd-numbered characters in the character string
I want to know the JSP of the open portlet when developing Liferay
[Active Admin] I want to customize the default create and update processing
I want to get the IP address when connecting to Wi-Fi in Java
I want to display an error message when registering in the database
I want to output the day of the week
I want to send an email in Java.
I tried to organize the session in Rails
I want to use arrow notation in Ruby
I want to var_dump the contents of the intent
I want to pass APP_HOME to logback in Gradle
I want to simply write a repeating string
rsync4j --I want to touch rsync in Java.
[Xcode] I want to manage images in folders
I want to be eventually even in kotlin
I want to write quickly from java to sqlite
I want to truncate after the decimal point
I want to change the path after new registration after logging in with multiple devises.
I want to morphologically analyze the log in the DB and put it in the DB to classify messages 1
[Active Admin] I want to specify the scope of the collection to be displayed in select_box
[Android Studio] I want to set restrictions on the values registered in EditText [Java]
I want to place RadioButtons in the same RadioGroup at any position on the screen.
[Rails] I want to display the link destination of link_to in a separate tab
# 1_JAVA I want to get the index number by specifying one character in the character string.
I was addicted to the NoSuchMethodError in Cloud Endpoints
I want to use Combine in UIKit as well.
I tried to organize the cases used in programming
I want to do something like "cls" in Java
[Java] I want to calculate the difference from the date
Tokoro I rewrote in the migration from Wicket 7 to 8
I want to use fish shell in Laradock too! !!
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
I want to judge the range using the monthly degree
I want to use a little icon in Rails
I want to know the answer of the rock-paper-scissors app
I want to display the name of the poster of the comment
I want to dark mode with the SWT app
I want to define a function in Rails Console
I want to stop snake case in table definition
I want to call the main method using reflection
If you want to recreate the instance in cloud9
I want to click a GoogleMap pin in RSpec