Reputation: 872
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. 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. 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
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. Is there any way to change how this mode uses tabs in my .emacs file. I currently have this in my .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))
Upvotes: 1
Views: 1710
Reputation: 872
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. This website has a very detailed explanation of how the tab key works in emacs and how to customize it.
Upvotes: 3