Skip to main content
15 votes
Accepted

turn off auto-quotes in web-mode

(setq web-mode-enable-auto-quoting nil) Add double quotes after the character = in a tag.
xuhdev's user avatar
  • 1,961
15 votes

How do I set up indentation to 2 spaces in web-mode

With use-package: (use-package web-mode :custom (web-mode-markup-indent-offset 2) (web-mode-css-indent-offset 2) (web-mode-code-indent-offset 2))
DomQ's user avatar
  • 297
8 votes
Accepted

Formatting jsx in js files with web-mode

The answer was to add the following to my init.el (setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'")))
dagda1's user avatar
  • 615
6 votes
Accepted

Change comment style in web-mode

web-mode-comment-formats is a buffer local variable. Also, add-to-list may not work correctly, since there is already a mapping for javascript to /*. You can try one of the following: (setq-default ...
punchagan's user avatar
  • 251
5 votes
Accepted

web-mode not installing?

I think what's happening is that the list of packages Emacs knows about is out of date; your system thinks web-mode 15 is the latest, but web-mode 16 has been published to the package repository. Your ...
zck's user avatar
  • 9,162
5 votes
Accepted

How to use web-mode engine-specific checkers in flycheck?

The following works, not sure if there's a "built-in" way of doing it... (flycheck-add-mode 'javascript-eslint 'web-mode) (defun my/configure-web-mode-flycheck-checkers () ;; in order to have ...
mgalgs's user avatar
  • 484
5 votes
Accepted

How to render html in web-mode?

You can find out what C-c C-v does by pressing F1 k C-c C-v in a html-mode buffer: C-c C-v runs the command browse-url-of-buffer (found in html-mode-map), which is an interactive autoloaded ...
wasamasa's user avatar
  • 22.4k
4 votes
Accepted

How can i start web-mode at a file's startup?

This line is in error: (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) It doesn't open .tpl files and .php files in web-mode, it opens files ending .tpl.php in web-mode. Amusingly, I ...
zck's user avatar
  • 9,162
4 votes
Accepted

Yasnippets for active web-mode engine

The right place to use yas-activate-extra-mode is web-mode-on-engine-setted since that function also sets the engine specific snippets of web-mode. Pityingly there is no hook so we have to add an ...
Tobias's user avatar
  • 33.7k
3 votes

Help with `replace-regexp-in-string`, to replace only first instance in every line

C-hf replace-regexp-in-string actually covers this exact requirement (or it does in Emacs 25.3, at any rate). To replace only the first match (if any), make REGEXP match up to \' and replace a sub-...
phils's user avatar
  • 53k
3 votes
Accepted

web-mode disable auto pairing mode does not work

In elisp nil represents a false value. Try: (setq web-mode-enable-auto-closing nil) (setq web-mode-enable-auto-pairing nil) -1 is non-nil (see: (if -1 "true!" "false!")).
ebpa's user avatar
  • 7,579
3 votes
Accepted

Select Within Quotes

You can use the expand-region or emacs-surround packages to select the text and then delete it. Watch an intro to expand-region on: Emacs Rocks. Or take a look at the examples of emacs-surround on ...
Alexandro de Oliveira's user avatar
3 votes

Detect missing > html emacs web-mode

web-mode maintainer here. I've pushed a fix to use web-mode-html-tag-unclosed-face instead of web-mode-html-tag-face as long as the tag remains unclosed. This face can be customised (e.g. adding a red ...
fxbois's user avatar
  • 452
3 votes
Accepted

Set web-mode engine per directory

Have you tried adding a web-mode-hook to check if you are in a projectile project? You would also have to check if the projectile project is a django one, but I am not that familiar with django. (...
CESCO's user avatar
  • 374
2 votes
Accepted

Web-mode uses 1 space indent instead of 2

Try (setq web-mode-script-padding 2). You should also call my-web-mode-hook only once, after you first load web-mode and not every time the mode is activated: (with-eval-after-load 'web-mode (my-...
caisah's user avatar
  • 4,126
2 votes
Accepted

how to get web-mode to ignore alignment in favor of indentation during method chaining?

ah, turns out it's the web-mode-indentation-params list: (add-to-list '(web-mode-indentation-params) '("lineup-calls" . nil))
Dan O's user avatar
  • 161
2 votes

go to symbol in javascript with web-mode

for javascript I highly recommend js2-mode. Take a look here https://elpa.gnu.org/packages/js2-mode.html it has function that you are looking for: js2-jump-to-definition which is by default bound to M-...
Jakub Ječmínek's user avatar
2 votes

go to symbol in javascript with web-mode

I submit critical patches to both web-mode and js2-mode. Currently as a front end architect, I'm developing a big ReactJS project from the scratch. The simple answer is: helm-etags+ctags or counsel-...
chen bin's user avatar
  • 4,957
2 votes
Accepted

Detect missing > html emacs web-mode

Use builit flymake plus old cli tidy. tidy is available on Mac/Linux/Windows, tested on Emacs 24.4 and Emacs 25.3: (defun flymake-html-init () (let* ((temp-file (flymake-init-create-temp-...
chen bin's user avatar
  • 4,957
2 votes

Help with `replace-regexp-in-string`, to replace only first instance in every line

You could look for the pattern "beginning of line, spaces, //, spaces" and replace that with the empty string: (replace-regexp-in-string "^\\s-*//\\s-*" "" comment)
Omar's user avatar
  • 4,852
2 votes
Accepted

Toggle major mode with a custom key binding

You can use the variable major-mode to find out the current Major Mode. The value is a Symbol, thus you can compare it using eq. (defun toggle-between-web-mode-and-js2-jsx-mode () (interactive) (...
xuchunyang's user avatar
  • 14.8k
2 votes

How to get current language at point?

web-mode-language-at-pos function is what are your looking for. Although it is not documented. Single function to get language at pos that will work across different modes might look like this: (...
muffinmad's user avatar
  • 2,340
2 votes

web dev environment setup

Install skewer-mode and js2-mode, then following below work flow: Add below config into init.el: (add-hook 'js2-mode-hook 'skewer-mode) (add-hook 'css-mode-hook 'skewer-css-mode) (add-...
beetlej's user avatar
  • 1,100
1 vote
Accepted

How to exclude or remove certain modes from major mode?

The doc of define-globalized-minor-mode says: When a major mode is initialized, MODE is actually turned on just after running the major mode’s hook. However, MODE is not turned on if the hook ...
Tobias's user avatar
  • 33.7k
1 vote
Accepted

javscript "." indent in web-mode

I can find the variable 'web-mode-indenation-params' from the source code of web-mode. Then also can find the manual from the official site You can disable arguments|concatenation|calls lineup with (...
ptmono's user avatar
  • 121
1 vote
Accepted

Help with `replace-regexp-in-string`, to replace only first instance in every line

You are likely looking for this: (setq comment (replace-regexp-in-string "^// " "" comment)) But are you sure you want to create a string and then act on it? A guess is that you really want to act ...
Drew's user avatar
  • 79.1k
1 vote

How to detect and match indentation size of current buffer

As Python allows to change the indent blockwise, there is related stuff in Python-modes. python-mode.el uses py-guess-indent-offset, built-in python.el uses python-indent-guess-indent-offset ...
Andreas Röhler's user avatar
1 vote

Why am i getting extra indentation-steps on react-router render function?

The version 14.1.17 of web-mode solves those two issues : https://github.com/fxbois/web-mode
fxbois's user avatar
  • 452
1 vote

How to use web-mode to edit multiline HTML inside backticks?

The version 14.1.16 of web-mode available on github provides this feature : https://github.com/fxbois/web-mode
fxbois's user avatar
  • 452

Only top scored, non community-wiki answers of a minimum length are eligible