Comandos
[Alt + / ] = Autocompletion
[Esc, C-s] = RegExp Search
[Ctrl + g, g] ou [Ctrl+g Ctrl+g] = Goto line
[Ctrl + @] ou [Ctrl + Space] = Marca o inicio da seleção de um texto;
[Alt + W] ou [Shift + Ins] = Copia da marca até a posicao do cursor;
[Ctrl + W] ou [Ctrl + Ins] = Recorta da marca até a posicao do cursor;
[Ctrl + K ] = Recorta linha inteira
[Ctr + Y] = Cola objeto copiado
[Ctrl + Alt + \ ] = Indenta um texto selecionado
[Ctrl + x , ( ] = Inicializa macro digitar comando da macro
[Ctrl + x , ) ] = Define o final da macro
[Ctr + x , e] = Executa a macro
[Alt + ; ] = Comenta texto selecionado
[Shift + <Btn Esq Mouse> ] = Popup Menu para mundar a font
[Ctrl + u , <space> ] = Volta posição do cursor pra ultima posição anterior
[Alt + x, gdb, <enter> ] = Entra no gdb dentro do emacs
[Ctrl + x, Ctrl + t] = Troca o conteúdo entre duas linhas
[Ctrl + t] = Troca o a ordem entre duas letras
[Alt + t] = Troca o a ordem entre duas palavras
[Ctrl + x, Ctrl + +] = Aumenta a fonte do buffer atual
[Ctrl + x, Ctrl + -] = Diminui a fonte do buffer atual
http://www.engr.uvic.ca/~dastone/emacs-keys.html
Janelas no Emacs
[Ctrl + x , 2 ] = Quebra Janela verticalmente
[Ctrl + x , 3 ] = Quebra Janela horizontalmente
Setando atalhos para mover entre janelas
(global-set-key (kbd "C-<kp-left>") 'windmove-left) ;; Ctrl + left
(global-set-key (kbd "C-<kp-4>") 'windmove-left) ;; NumLock Ativado
(global-set-key (kbd "C-<kp-right>") 'windmove-right) ;; Ctrl + right
(global-set-key (kbd "C-<kp-6>") 'windmove-right) ;; NumLock Ativado
(global-set-key (kbd "C-<kp-up>") 'windmove-up)
(global-set-key (kbd "C-<kp-8>") 'windmove-up) ;; NumLock Ativado
(global-set-key (kbd "C-<kp-down>") 'windmove-down)
(global-set-key (kbd "C-<kp-2>") 'windmove-down) ;; NumLock Ativado
Setando funcoes e atalhos para redimensionar janelas
(global-set-key (kbd "S-M-<kp-left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-M-<kp-right>") 'enlarge-window-horizontally)
(global-set-key (kbd "M-S-<kp-down>") 'shrink-window)
(global-set-key (kbd "M-S-<kp-up>") 'enlarge-window)
Para permitir voltar janelas fechadas
(winner-mode)
[Ctrl + c , <left>] = undo de janela
[Ctrl + c, <right>] = redo de janela
Window Handling Convenience Features and Customization http://www.ldc.usb.ve/docs/emacs/Windows.html#Windows
M-x winner-mode is a global minor mode that records the changes in the window configuration (i.e. how the frames are partitioned into windows), so that you can “undo†them. To undo, use C-c left (winner-undo). If you change your mind while undoing, you can redo the changes you had undone using C-c right (M-x winner-redo). Another way to enable Winner mode is by customizing the variable winner-mode. The Windmove commands move directionally between neighboring windows in a frame. M-x windmove-right selects the window immediately to the right of the currently selected one, and similarly for the “left,†“up,†and “down†counterparts. M-x windmove-default-keybindings binds these commands to S-right etc. (Not all terminals support shifted arrow keys, however.) Follow minor mode (M-x follow-mode) synchronizes several windows on the same buffer so that they always display adjacent sections of that buffer. See Follow Mode. M-x scroll-all-mode provides commands to scroll all visible windows together. You can also turn it on by customizing the variable scroll-all-mode. The commands provided are M-x scroll-all-scroll-down-all, M-x scroll-all-page-down-all and their corresponding “up†equivalents. To make this mode useful, you should bind these commands to appropriate keys.
Várias abas
No ubuntu/debian, sudo apt-get install emacs-goodies-el
e entao ativar o modo com Alt+x tabbar-mode
[Ctrl + c, C -Up ] = Down muda de grupo
[Ctrl + c, C -Esq ] = Dir muda de aba
Abrir arquivo remoto no emacs
C-x C-f
/host:filename
/user@host:filename
/user@host#port:filename
/method:user@host:filename
/method:user@host#port:filename
/ftp:user@host:filename
Exemplo
/ssh:raXXXXXX@ssh.students.ic.unicamp.br:filename
ou
/ssh:raXXXXXX@ssh.students.ic.unicamp.br: [ enter ]
para navegar pelos arquivos da pasta home
http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html
Emacs Client and Server
Usando o emacs client, a segunda instancia do emacs será aberta muito mais rápido e tambem nao reabre arquivo ja abertos
para usar isto de maneira transparente aqui vao os passos
adicione a linha no seu .emacs
(server-start)
e a seguinte funcao no seu .bashrc
function emacs {
if [ $(pidof /usr/bin/emacs-snapshot-gtk) ]; then \
/usr/bin/emacsclient.emacs-snapshot -c -a emacs-snapshot $1 & \
else \
/usr/bin/emacs-snapshot-gtk $1 & \
fi
}
para testar
# emacs
# emacs
Terminal dentro do emacs
M-x shell
M-x eshell
M-x term
M-x ansi-term
Emacs + Cscope
To Install in Debian/Ubuntu
sudo apt-get install cscope
write this 2 lines in you .emacs
...
(load-file "/usr/share/emacs/site-lisp/xcscope.el")
(require 'xcscope)
...
Then, if you have code in ~/mycode, cd to that directory and run
Code:
myusernam@mycomputer:~/mycode$ cscope-indexer -r
run emacs
myusernam@mycomputer:~/mycode$ emacs main.c
put the cursor on the word you want to search and
[Alt+x] (and one of the the options bellow)
cscope-find-called-functions
cscope-find-egrep-pattern
cscope-find-files-including-file
cscope-find-functions-calling-this-function
cscope-find-global-definition
cscope-find-global-definition-no-prompting
cscope-find-this-file
cscope-find-this-symbol
cscope-find-this-text-string
Indentar código automaticamente usando emacs na linha de comando
.emacs
--------------------------------------------------------------------------------------
;; Coding Style for Enlightenment Foundations Libraries
(c-add-style
"e17"
'("gnu"
(indent-tabs-mode . t)
(tab-width . 8)
(c-offsets-alist
.
((defun-block-intro . 3)
(statement-block-intro . 3)
(case-label . 1)
(statement-case-intro . 3)
(inclass . 3)
))))
-----------------------------------------------------------------------------------------
Indentar codigo na linha de comando sem abrir o emacs
emacs -batch main.c --eval '(lambda() (c-set-style "e17") (indent-region (point-min) (point-max) nil))' -f save-buffer
emacs --batch filevisitor.cpp --eval "(progn (indent-region (point-min) (point-max) nil) (save-buffer))"
Todos os arquivo do diretório
for i in *; do emacs -batch $i --eval '(lambda() (c-set-style "e17") (indent-region (point-min) (point-max) nil))' -f save-buffer; done;
Indentar usando alguma funcao do seu .emacs
emacs --batch filevisitor.cpp -l ~/.emacs --eval "(progn (c-set-style "java") (indent-region (point-min) (point-max) nil) (save-buffer))"
emacs -batch $1 -l ~/.emacs -f emacs-format-function