Emacs/Evil mode - how can I set TAB to cycle buffers? - emacs

I would like to configure my Emacs/Evil so that when in normal mode (i.e. after hitting ESC and navigating inside the file) then the TAB key switches to the next buffer, and Shift-TAB switches to the previous one. I tried this in my .emacs ...
(define-key evil-normal-state-map (kbd "\t") 'evil-next-buffer)
(define-key evil-normal-state-map (kbd "S-\t") 'evil-prev-buffer)
...but it didn't work.
Since that motion is muscle-memoried in my fingers, I'd appreciate any help on making this work.

You need to use <tab> to set a tab binding. Try these commands instead.
(define-key evil-normal-state-map (kbd "<tab>") 'evil-next-buffer)
(define-key evil-normal-state-map (kbd "<backtab>") 'evil-prev-buffer)

Related

How to properly bind cider-switch-to-repl-buffer to <C-tab>?

I tried
(eval-after-load 'cider
'(progn
(define-key cider-mode-map (kbd "<C-tab>") 'cider-switch-to-repl-buffer)
(define-key cider-repl-mode-map (kbd "<C-tab>") 'cider-switch-to-repl-buffer)))
But it only works in the buffer, i.e. I can switch from the buffer to the repl, but not the other way around. What I'm trying to achieve is to use C-tab to switch back and forth between the buffer and the repl.
Thanks!
I think the function you want to bind in the repl is cider-switch-to-last-clojure-buffer, eg
(with-eval-after-load "cider-mode"
(define-key cider-repl-mode-map (kbd "<C-tab>")
'cider-switch-to-last-clojure-buffer))

Can I bind action to a keypress in Emacs?

I have (kbd "C-c S-<down>") and (kbd "C-c S-<up>") bound to shrink-window and enlarge-window, respectively.
It works, but I also want Emacs to change window size during a keypress, while I am holding S-<down> or S-<up>.
Is it possible in Emacs?
(define-key global-map [S-up] 'enlarge-window)
(define-key global-map [S-down] 'shrink-window)

How do I scroll through the autocomplete options in emacs-jedi (besides arrow keys)

Up and down arrow keys work but I was wondering if there was another option on the home row. If not, how do I set it to something else? (emacs noob)
emacs-jedi uses auto-complete under the hood
These are also supported (besides the default arrows):
M-n Next item
M-p Previous item
If you wanted to change them you could do something like this:
(define-key ac-completing-map (kbd "C-c j") 'ac-next)
(define-key ac-completing-map (kbd "C-c k") 'ac-previous)

Use TAB for expand and C-i for indent-relative in emacs

how can i use TAB for dexpand and still have C-i for indent-relative?
Im trying:
(global-set-key (kbd "TAB") 'dabbrev-expand)
(global-set-key "\C-i" 'indent-relative)
but it wont work, because both TAB and C-i are used for dabbrex-expand.
If you never use emacs in terminal then you can do the following
First separate C-i and tab by doing
(define-key key-translation-map [tab] [?\t])
(define-key key-translation-map [?\C-\i] [(control i-key)])
(define-key function-key-map [tab] nil)
(define-key function-key-map [?\t] nil)
Then you can bind commands to the keys as usual
(global-set-key (kbd "TAB") 'dabbrev-expand)
(global-set-key (kbd "<C-i-key>") 'indent-relative)
Credits: I picked this up from this comment by Fuco.

emacs -nw issues with cscope and terminals

Few issues with emacs in term windows. Any help is appreciated.
a. I start emacs over ssh with emacs -nw with cscope enabled. After I search for a symbol or a definition, on the cscope buffer when i press 'enter', emacs says - Buffer is read-only. Whereas the same functionality on emacs with xwindows (gtk or anything else) takes me to the file and line on edit buffer. How can I have the same functionality with 'emacs -nw'.
b. Also the arrow mark on edit/source buffer when i do next reference for symbol from cscope buffer stays on the edit buffer. How can I make it go?
c. My keys are mapped to cscope functions just like in xcscope.el. All the control keys expect Ctrl-F3 and Ctrl-F4 work. How can I enable this too.
Thanks much,
a. Add the following to your .emacs file:
(define-key global-map (kbd "\r") [return])
I got the answer from http://weenix.cs.brown.edu/mediawiki/index.php/Cscope
b. If you hit the space bar in the cscope buffer, you will get the arrow. It's just a display thing; the file has not changed. If you want to get rid of it, add the following to your .emacs file:
(setq cscope-allow-arrow-overlays nil)
terminal send different key sequences than emacs may be expecting. you need to provide translations for the terminal type in order to get emacs to work correctly. for example, i have this config to setup the terminal i use (the weird char is a literal "escape" char, which you can type in using "C-q <esc>":
(let ((map (if (boundp 'input-decode-map)
input-decode-map function-key-map)))
(define-key map (kbd "RET") [return])
(define-key map "[OA" (kbd "<C-up>"))
(define-key map "[OB" (kbd "<C-down>"))
(define-key map "[OC" (kbd "<C-right>"))
(define-key map "[OD" (kbd "<C-left>"))
(define-key map "[A" (kbd "<C-up>"))
(define-key map "[B" (kbd "<C-down>"))
(define-key map "[C" (kbd "<C-right>"))
(define-key map "[D" (kbd "<C-left>"))
(define-key map "OA" (kbd "<M-up>"))
(define-key map "OB" (kbd "<M-down>"))
(define-key map "OC" (kbd "<M-right>"))
(define-key map "OD" (kbd "<M-left>"))
(define-key map "[OA" (kbd "<M-C-up>"))
(define-key map "[OB" (kbd "<M-C-down>"))
(define-key map "[OC" (kbd "<M-C-right>"))
(define-key map "[OD" (kbd "<M-C-left>"))
(define-key map "[[17~" (kbd "<C-f6>"))
(define-key map "[[18~" (kbd "<C-f7>"))
(define-key map "[[19~" (kbd "<C-f8>"))
(define-key map "[[20~" (kbd "<C-f9>"))
(define-key map "[[21~" (kbd "<C-f10>"))
(define-key map "[[23~" (kbd "<C-f11>"))
(define-key map "[[24~" (kbd "<C-f12>"))
(define-key map "\e[1~" [home])
(define-key map "\e[4~" [end])
(define-key map "\e\e[1~" [M-home])
(define-key map "\e\e[4~" [M-end])
)
in some terminals, you can get the key code by typing "C-v" and then the desired keys. this should output the actual keycodes that the terminal sends for the keys you pressed after the "C-v".