[英]Emacs web-mode tabs not working
I am using emacs web-mode to edit my php files and have noticed that the tab key doesn't work the way I expect it to in a couple of different situations. 我正在使用emacs网络模式来编辑我的php文件,并且注意到tab键在几种不同的情况下无法按我期望的方式工作。 For example if I have a string that spans multiple lines like this... 例如,如果我有一个像这样跨多行的字符串...
<?php
return "
<nav>
<a href='index.php?page=skills'>My skills and background</a>
<a href='index.php?page=projects'>Some projects</a>
</nav>
";
?>
and I go to the beginning of the lines with anchor tags and press tab nothing happens. 然后转到带有定位标记的行的开头,然后按Tab键,则什么也没有发生。 I have to use the space bar to indent the lines the way I want. 我必须使用空格键以所需的方式缩进线条。
The other situation is occurs inside of a php block for example 例如,另一种情况是在php块内发生的
<?php
error_reporting( E_ALL );
ini_set( "display_errors", 1);
$pageData = new stdClass();
$pageData->title = "Jordan: Portfolio site";
$pageData->content = include_once "views/navigation.php";
$navigationIsClicked = isset($_GET['page']);
if($navigationIsClicked) {
$fileToLoad = $_GET['page'];
$pageData->content .= "<p>Will soon load $fileToLoad.php</p>";
}
$page = include_once "templates/page.php";
echo $page;
?>
if I go to one of the variable assignment lines and push tab nothing happens, again spaces work fine, then inside the if block only 1 tab is allowed. 如果我转到变量赋值行之一,而推键没有任何反应,那么空格也可以正常工作,然后在if块内部仅允许1个键。 Is there any way to change how this mode uses tabs in my .emacs file. 有什么方法可以更改此模式使用.emacs文件中的选项卡的方式。 I currently have this in my .emacs 我目前在我的.emacs中有这个
(defun my-setup-php ()
;; enable web mode
(web-mode)
;; make these variables local
(make-local-variable 'web-mode-code-indent-offset)
(make-local-variable 'web-mode-markup-indent-offset)
(make-local-variable 'web-mode-css-indent-offset)
;; set indentation, can set different indentation level for different code type
(setq web-mode-code-indent-offset 4)
(setq web-mode-css-indent-offset 2)
(setq web-mode-markup-indent-offset 2))
(add-to-list 'auto-mode-alist '("\\.php$" . my-setup-php))
As it turns out my question is completely unrelated to web-mode. 事实证明,我的问题与网络模式完全无关。 The function that emacs binds to the tab key by default is called indent-for-tab-command
the function I was looking for is called tab-to-tab-stop
which by default is bound to M - i. emacs默认情况下绑定到tab键的功能称为indent-for-tab-command
而我一直在寻找的功能称为tab-to-tab-stop
,默认情况下绑定至M-i。 This website has a very detailed explanation of how the tab key works in emacs and how to customize it. 该网站非常详细地说明了Tab键在emacs中的工作方式以及如何对其进行自定义。
您应该尝试(setq-default indent-tabs-mode t)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.