I used to have a configuration for TAB which was doing something like this :
This is the code before hitting TAB.
template<typename T>
class A
{
}; // This is where I hit TAB
The code auto-indented as below after hitting TAB:
template<typename T>
class A
{
};
The TAB key used to work as above but now it does only auto-complete.
Can I fix this ? I can use TAB with C-qTAB but it is hard to do always.
Here is my .emacs file
(add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp")
(load "jde")
(add-to-list 'load-path "~/.emacs.d")
(require 'linum)
(global-linum-mode 1)
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(yas-global-mode 1)
; care about this place
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
; care about this place
(setq ac-source-yasnippet nil)
(add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(global-auto-complete-mode t) ; section1
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers))
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
(add-to-list 'load-path "~/.emacs.d/iedit")
(require 'iedit)
(define-key global-map (kbd "C-c ;") 'iedit-mode)
(semantic-mode 1)
(defun my:add-semantic-to-autocomplete()
(add-to-list 'ac-sources 'ac-source-semantic)
)
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
'(cua-mode t nil (cua-base))
'(custom-enabled-themes (quote (tango-dark)))
'(font-use-system-font t)
'(show-paren-mode t)
'(uniquify-buffer-name-style (quote forward) nil (uniquify)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight bold :height 113 :width normal)))))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq indent-line-function 'insert-tab)
Edit When I add JDE it fixed but now I cannot use auto-complete ? It doesn't complete anything.
newline-and-indent
for automatic indentation:(global-set-key (kbd "RET") 'newline-and-indent)
. You can indent whole buffer or region (if selected) using the code snippet here.