Note that I use spaces for tabs. When I am working in erb files for rails such as example.js.erb or example2.html.erb, I am getting some very odd (and annoying) auto-tabbing behaviour, which I can't figure out.
For example, in a js.erb file I'll type:
function blaah(){ //a comment
var a = 5;
}
Then I'll press tab on each line and I'll get
function blaah(){ //a comment
var a = 5;
}
It would appear as though the 2nd line is attempting to align with the comment above, but for what reason I do not know.
Here is my .emacs file:
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/")
t)
(package-initialize)
(load-theme 'misterioso)
(setq inhibit-splash-screen t)
; remove tool/scroll bars
(tool-bar-mode -1)
(scroll-bar-mode -1)
; (row,column) shown in bottom bar
(line-number-mode)
(column-number-mode 1)
; line numbers on the left
(global-linum-mode 1)
; highlight current line num
(require 'hlinum)
(hlinum-activate)
(setq hl-line-sticky-flag nil)
(require 'smartparens)
(smartparens-global-mode t)
(require 'smartparens-config)
(sp-pair "%" "%" :wrap "C-%")
(add-to-list 'load-path "c:/Users/darre00/AppData/Roaming/.emacs.d/web-mode-master")
(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))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-enable-auto-pairing nil)
(require 'json-mode)
(add-hook 'json-mode-hook 'hs-minor-mode)
(require 'org)
;; Make org-mode activate automatically for files ending in .org
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
(global-set-key (kbd "C-+") 'er/contract-region)
; scrolling starts 2 lines away from top/bottom
(setq scroll-margin 2
scroll-preserve-screen-position 1)
; indentation
(setq-default c-basic-offset 2)
(setq-default js-indent-level 2)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default web-mode-code-indent-offset 2)
; full file path in title bar
(setq-default frame-title-format '((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name)) "%f"))))
(ido-mode 1)
; FUNCS
(defun kill-dired-buffers()
"Kill all dired buffers open."
(interactive)
(mapc (lambda (buffer)
(when (eq 'dired-mode (buffer-local-value 'major-mode buffer))
(kill-buffer buffer)))
(buffer-list)
)
(message "Killed all dired buffers")
)
(defun toggle-comment ()
"comment or uncomment region or line"
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)))
; KEYBINDINGS
(global-set-key (kbd "C-c k") 'kill-dired-buffers)
(global-set-key (kbd "C-c /") 'toggle-comment)
Any help is much appreciated.