I have installed the multiple-cursors package but, I cannot manage to work properly. Only one cursor can be modified, the rest of the cursors do nothing.
I have configured my .emacs file for the multi-cursors package as is shown below:
(require 'multiple-cursors)
(global-set-key (kbd "C-c m 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)
Can anybody help with this?
Thanks.
My crystal ball tells me that once upon a time the original poster was presented with an interactive question asking him/her whether to perform the same command for all cursors; and, the O.P. answered the question with a "no". Whereupon the Multiple Cursors package added an entry to the mc/lists-file, which has a default location of: (locate-user-emacs-file ".mc-lists.el") -- see https://github.com/magnars/multiple-cursors.el/blob/master/multiple-cursors-core.el#L652
The O.P. should open up the above-mentioned file and see if his/her prior choice should be manually removed. The file contains something like this:
;; This file is automatically generated by the multiple-cursors extension.
;; It keeps track of your preferences for running commands with multiple cursors.
(setq mc/cmds-to-run-for-all
'(
my-custom-function-one
org-self-insert-command
))
(setq mc/cmds-to-run-once
'(
mime-preview-scroll-down-entity
my-custom-function-two
))
(provide '.multiple_cursors)
Related
When I press C-S-c, the echo area shows only C-c. Things like C-S- selection do work, however.
I'm in Ubuntu 14.10 Utopic Unicorn in case this helps.
Here's the code for the key binding (for multiple cursors) in my .emacs:
;; multiple cursors
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
Is C-S-c defined as a prefix key; i.e., is it bound to a keymap? When do you see C-c in the minibuffer -- is it when you use the first C-S-c, in preparation for using it a second time?
The following works for me. If something similar doesn't work for you, consider filing a bug report, providing a step-by-step recipe: M-x report-emacs-bug.
(define-prefix-command 'foo)
(global-set-key (kbd "C-S-c") 'foo)
(define-key foo (kbd "C-S-c") 'open-line)
Then pressing C-S-c shows C-S-c in the minibuffer (actually, in the echo area), while waiting for another key. If I then press C-s-c again, command open-line is invoked.
This is probably simple, but I've been trying it for a couple days now without success. I have a tag called :urgent:, which I can access through:
C-c / m urgent
Question is, how can I create a shortcut to get it done with, say, f9?
(defun hello-world ()
"My doc-string."
(interactive)
(org-tags-view nil "urgent"))
(global-set-key [f9] 'hello-world)
;; or, use the following form instead of the one immediately above:
;; (define-key global-map [f9] 'hello-world)
I want Emacs to work like this:
Let auto-complete auto-popup menu:
(setq ac-auto-show-menu 0.8)
(setq ac-delay 0.1)
Use C-n/p / M-n/p to select auto-complete popup menu candidates:
(define-key ac-menu-map (kbd "M-n") 'ac-next)
(define-key ac-menu-map (kbd "M-p") 'ac-previous)
When selecting a candiate
disable TAB / S-TAB in popup menu selection:
(define-key ac-menu-map (kbd "<tab>") nil)
(define-key ac-menu-map (kbd "<S-tab>") nil)
press Enter to select the candiate, without inserting newline:
;; ???
if the candidate is an abbrev, Enter should only select the candiate:
;; ???
... and pressing Space should cause Emacs to auto-expand the abbrev.
if the candidate is a dabbrev, pressing M-\ on candidate should trigger dabbrev-expand.
pressing TAB / C-i to expand the candidate for yasnippet:
(setq yas-trigger-key "TAB")
I set this, but the trigger does not expand when I press TAB.
pressing TAB to expand a snippet trigger while in a field:
(setq yas-triggers-in-field t)
pressing C-j to jump to next field:
(setq yas-next-field-key '("<tab>")) ;; or "C-j"
How can I expand a snippet within a snippet using yasnippet?
Some explanations
There are two TABs in Emacs:
(kbd "TAB") / (\t, [9])
(kbd "<tab>") / ([tab])
If modes like yasnippet and auto-complete want to bind to TAB, their trigger key must be the same as the original tab command. Since Emacs binds indent-for-tab-command to (kbd "TAB"), it's better to use that as the trigger key. yasnippet binds to it by default, and it is easy to set up auto-complete to trigger using TAB as well:
;; trigger using TAB and disable auto-start
(custom-set-variables
'(ac-trigger-key "TAB")
'(ac-auto-start nil)
'(ac-use-menu-map t))
But in some modes (ruby-mode, markdown-mode, org-mode, etc.), the command is bound to
(kbd "<tab>"). When the real tab key is typed, the function bound to (kbd "<tab>) has higher priority, so yasnippet and auto-complete are not invoked. This is easy to fix by moving the key binding:
(defun iy-tab-noconflict ()
(let ((command (key-binding [tab]))) ; remember command
(local-unset-key [tab]) ; unset from (kbd "<tab>")
(local-set-key (kbd "TAB") command))) ; re-bind to (kbd "TAB")
(add-hook 'ruby-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'markdown-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'org-mode-hook 'iy-ac-tab-noconflict)
My setup
I downloaded yasnippet, auto-complete via the el-get packager manager. I'm using Ubuntu 12.04 and Emacs 24.3.50.1.
Wrapping up
I know this problem is a little long, but it really makes it difficult for me to use auto-complete and yasnippet. If the basic key binding doesn't work smoothly, this slows down my workflow quite a bit. I think many people have similar problems because I found some similar questions on the internet (though none of them are exactly like mine).
As you can see above, some of the relevant settings I already know. (But if you think I made a mistake somewhere, please tell me.) There are also some things I still don't know how to set up (???). Maybe there isn't a way to make all of these settings work together? Let me know if that is the case, and otherwise please make sure none of these setting interfere with each other.
After I get the answer to this question, I hope to write an Emacs extension to initialize all of these settings automatically.
Thanks for your help!
I faced the problem you're describing a long time ago and resolved it like this:
bind auto-complete to TAB (also C-i which is the same)
and yasnippet to C-o.
Abbrevs are on C-o as well, but I don't use them a lot.
The advantages are:
No stateful behavior results in a much more relaxed and productive editing.
You no longer think "what will TAB do in this context?" before pressing,
you just press it.
You no longer check if you got the expected outcome, because there's only one.
You can use auto-complete while in the process of expanding yasnippet.
C-i and C-o are neighbors and very easy to press.
Yasnippets now expand reliably in any mode since no mode overrides C-o.
This may be not what you want right now but consider trying it:
you might like it after a while.
Bind RET or <return> to function ac-expand. This is for select candidate.
A related question was asked here. But the answer is to get used to the new way autocomplete works in helm. I cannot get used to it, here's why.
Say, I want to open a file /home/user/work/f.txt. I do C-x C-f, it takes me to current dir, say /current/dir/. I hit Backspace and notice that autocomplete won't let me delete /. Ok, turn off autocomplete with C-Backspace. Then kill the line C-a C-k and start typing. Notice that autocomplete doesn't work, turn it back on C-Backspace. Normally I would type the part that I know is probably unique, e.g. /hom and hit Tab.
Not here. As soon as I type /ho, autocomplete resolves it to /home/, but since I type fast, I end up with /home/m, and continue typing now meaningless characters until I notice it. Chances are, by that time I got autocompleted into directories that I had no intent of going.
So I have to constantly watch what autocomplete is doing, rather than rely on what I type and only checking suggested completions when I hit Tab.
I also find myself descending into wrong directories due to occasional typo, and then having difficulty going up a level -- evil autocomplete won't let you fix the situation with a couple of Backspaces.
This interaction of autocomplete behavior and the removal of Tab functionality completely upsets my work, so much that I decided to ask this question. I am looking to either:
restore the old functionality
learn how to use autocomplete in a meaningful way, or
configure helm's C-x C-f to behave more like a linux command line
Please help.
Here are some ido tricks if you want to start using it.
Let me know if helm is better, perhaps I'll switch over.
I tried once shortly, but didn't like it.
Basic setup:
This will give you `ido-find-file on C-x C-f.
(ido-mode)
(setq ido-enable-flex-matching t)
Smex setup:
Install from https://github.com/nonsequitur/smex.
(require 'smex)
(global-set-key "\C-t" 'smex)
Switch buffers with ido:
(global-set-key
"η"
(lambda()(interactive)
(when (buffer-file-name)
(save-buffer))
(ido-switch-buffer)))
(global-set-key
(kbd "C-η")
(lambda()(interactive)
(let ((ido-default-buffer-method 'other-window))
(ido-switch-buffer))))
Tricks:
;; 1
(add-hook 'dired-mode-hook
(lambda()
(define-key dired-mode-map "j" 'ido-find-file)))
(add-hook
'ido-setup-hook
(lambda()
;; 2
(define-key ido-file-dir-completion-map "~"
(lambda ()(interactive)
(ido-set-current-directory "~/")
(setq ido-exit 'refresh)
(exit-minibuffer)))
;; 3
(define-key ido-buffer-completion-map "η" 'ido-next-match)
;; 4
(define-key ido-buffer-completion-map (kbd "C-p")
'ido-fallback-command)
;; 5
(define-key ido-completion-map (kbd "C-.") 'smex-find-function)
(define-key ido-completion-map (kbd "C-,") 'smex-describe-function)))
Quick open file from dired.
Move to home directory one key faster (i.e. ~ instead of ~/).
Cycle buffer candidates with the same key that shows the candidates (a la C-TAB in Firefox).
Useful to have a fall back when you want to create a file-less buffer (ido will try
select an existing buffer unless you fall back).
Useful to jump to function definition/documentation.
If you want TAB completion of directories and file names, map helm-execute-persistent-action to the TAB key:
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
See also the answer to "How can I change emacs helm-find-file default action[...]".
I would like to associate a keyboard binding in Emacs (e.g. C-c a) that automatically starts an ansi-term window with a shell that I have pre-specified in my .emacs file (without prompting anything)
For reference, there are two threads in StackOverflow that address similar problems:
Remote ssh connection from within Emacs
Emacs: Default binary to run with M-x ansi-term
but it isn't obvious to me how to combine the ideas in those threads to get an answer to my question.
(global-set-key (kbd "C-c a") '(lambda () (interactive) (ansi-term "/bin/zsh")))
I suggest you to use multi-term. As its name implies, it lets you deal with multiple term using ansi-term.
Here is a small configuration:
(require 'multi-term)
(eval-after-load "multi-term"
'(setq multi-term-program "/bin/bash"
term-unbind-key-list '("C-x"
"C-h"
"M-x"
"C-z")
term-term-name "xterm-256color"))
(global-set-key (kbd "C-c a") 'multi-term-next)
My whole configuration for multi-term is
here
(compilation-shell-minor-mode is really nice).