In emacs 23 there was an option where we can select the word with mouse and using cntrl+s we can paste that word to search.
Unfortunately this is not working in emacs 25. I didnt change the configuration file . I took the emacs code from the git hub and compiled. I am using Centos6.4 version
I have already tried this
(setq select-enable-clipboard t)
and
(x-get-selection-value)
But none of it helped me
You could simply (!) select the word with the mouse and type M-w C-s RET C-y RET C-s C-s
Here are the details:
select the word with the mouse
M-w (to copy to clipboard)
C-s RET (to start incremental search and switch to non-incremental search)
(or 'FIND' if you have this key on your keyboard)
C-y (to paste from clipboard)
RET (to start searching)
C-s C-s (to search other occurrences)
Add (setq x-select-enable-clipboard t) to your .emacs
Related
I have a block of code like this:
ec2_shell_exec(tag: "ls /
ec2_shell_exec(tag: "sudo yum install git-core
ec2_shell_exec(tag: "pwd
Whats the easiest way to add a ") to this block of code?
Please note, emacs runs in terminal mode aka -nw mode.
Interactively
C-M-% $ RET ") RET
don't forget to press 4 keys at the same time: Ctrl for C, Alt for M, and Shift-5 for %
if the above still does not work (e.g., you are in a terminal with emacs -nw), you can do M-x query-replace-regexp RET $ RET ") RET
Programmatically
(while (not (eobp)) ; you have to edit the condition!
(goto-char (line-end-position))
(insert "\")")
(forward-line))
A keyboard macro should be easy to type on most terminals:
Move to your first line
Start recording a keyboard macro with C-x (
Go to end of line with C-e
Type ")
Move down with C-n
Stop recording macro with C-x )
Type C-x e to replay once
Type e for each successive time you need to repeat it
Summarizing the two solutions here (for folks running emacs in terminal):
M-x query-replace-regexp RET $ RET ") RET
And
first highlight ec2_shell_exec(tag. And call mc/mark-all-like-this which is from multiple-cursor. You will see all ec2_shell_exec(tag being hightlighted. Now call end-of-line to move every cursor to the end. Finally, you can insert anything you want. Press C-g to end operation
video demo: https://www.youtube.com/watch?v=jNa3axo40qM
Thanks adobe and tom!
Is there any simple command to do this? I'm tired to type C-x C-f ENTER.
If you (require 'dired-x) in your init file (or alternatively follow the autoloading instructions1), you can use C-xC-j to call dired-jump, which not only does what you want (in both file-visiting buffers and also in dired buffers), but also places point on the dired entry for the file or directory that you have just come from, which can be incredibly convenient.
1 C-hig (dired-x) Optional Installation Dired Jump RET
There isn't a single command to do that as far as I know, but since you are using emacs you can easily define one. Add these to your init file
(defun my-open-dired-here ()
(interactive)
(dired default-directory))
The above defines a command to open dired in current buffer's directory, this is what you get when you do C-x C-f RET in vanilla emacs.
You can bind the above command to a key of your choice I am binding it to F6
(global-set-key (kbd "<f6>") 'my-open-dired-here)
Now when you press F6 you will get dired opened in current buffer's directory.
When using python-mode in Emacs, I first split the screen via C-x 3.
I'd like to be able do C-c ! to launch py-shell in the other window, not in the window currently active. How can I configure Emacs to do that without having to switch windows with C-x o before launching the shell?
I'm using Emacs 24.3.1, and I've got all my configuration files in ~/.emacs.d.
I just installed the python-mode package using package-install with the Marmalade repository, and I haven't yet edited any .el file related to python-mode.
As #BleedingFingers says you can simply use a macro and bind that to a key. It's up to you whether or not you want to re-use the C-c ! binding for the macro or bind it to a different key.
Here's how to proceed should you decide to go with the macro option, starting with Emacs showing only a single window:
Define macro
F3
C-x 3
C-x o
M-x py-shell RET
C-x o
F4
Assign name to macro
M-x name-last-kbd-macro RET py-shell-other-window RET
You can replace py-shell-other-window with whatever name you would like to use for the macro.
Add macro to your configuration
Open your configuration file, move point (cursor) to an empty line and do
M-x insert-kbd-macro RET
This will insert the macro definition into your configuration file.
Bind macro to key
Add the following code to your configuration file to bind the macro to a key in python-mode:
(require 'python-mode) ; Make sure python-mode-map is available
; for modification
(define-key python-mode-map (kbd "C-c !") nil) ; Unset default binding
; for C-c !
; (not necessary if you choose an
; unused binding)
(define-key python-mode-map (kbd "C-c !") 'py-shell-other-window) ; Bind macro to C-c !
Turn key binding on
Mark the lines added in the previous step and run M-x eval-region RET, or simply restart Emacs.
Celebrate :)
Advice lets you redefine code in other libraries on-the-fly.
(defadvice py-shell (around auto-split activate)
(split-window-right)
(other-window)
,ad-do-it
(other-window))
Variations apply.
When using query-replace (with or without regexp) in emacs, the previous query-replace pair is remembered and suggested as default the next time query-replace is invoked. But I would like to be able to edit this default replacement to something similar without having to type the entire new variant.
Like this:
in a section of a long document I do a query-replace
M-% antidisestablishmentarianism-A [return] antidisestablismentarianism-B
later on in the same document I want to do
M-% antidisestablishmentarianism-A [return] antidisestablismentarianism-C
The command M-% on its own gives
Query-replace (default antidisestablishmentarianism-A -> antidisestablismentarianism-B):
Is there some magic key combination which makes it possible to change that final "B" to a "C" without retyping?
Yah, try M-p, something like this sequence
M-% M-p [return] M-p [DEL] C [return]
I can also use C-r. It shows me all the entries in minibuffer and I can select from that. I have C-r binded to M-x anything-minibuffer-history. After M-x query-replace, hit C-h b and search for major-mode in the Help buffer. That will give full list of command. Here is my bindings.
C-g abort-recursive-edit
TAB self-insert-command
C-j exit-minibuffer
RET exit-minibuffer
C-r anything-minibuffer-history
ESC Prefix Command
C-tab file-cache-minibuffer-complete
down next-history-element
next next-history-element
prior previous-history-element
up previous-history-element
M-n next-history-element
M-p previous-history-element
M-r previous-matching-history-element
M-s next-matching-history-element
In Org-mode it is possible to have links and top open links. As listed by http://orgmode.org/orgcard.txt in Org-mode C-u C-c C-o or mouse-3 forces links to open in another window. How can I do the corresponding for frames, that is, how can I force a link to open in another frame?
What I want is for C-c C-o to work as per default but C-u C-c C-o to force the link to be opened in another frame.
(For the distinction of windows and frames see http://www.gnu.org/software/emacs/manual/html_node/emacs/Frames.html.)
I am running Org-mode 7.6 in 23.3.1.
I just tested and you can get it to work by wrapping org-open-at-point in a (let ) as a custom function.
In this case I'm just prefixing the current org-link-frame-setup with your desired find-file-other-frame to ensure that if you use the command on another link type it will not fail.
(defun zin/org-open-other-frame ()
"Jump to bookmark in another frame. See `bookmark-jump' for more."
(interactive)
(let ((org-link-frame-setup (acons 'file 'find-file-other-frame org-link-frame-setup)))
(org-open-at-point)))
I suspect you will need to bind it to a key sequence other than C-u C-c C-o, unless Emacs will permit you to bind it to that sequence specifically.
Have a look at the variable org-link-frame-setup (M-x customize-variable RET org-link-frame-setup). The docstring should explain the approach.
I just tested this in a non-customized emacs:
emacs -q
GNU Emacs 24.0.92.1 (i386-mingw-nt5.1.2600) of 2011-11-30 on MARVIN
Org-mode version 7.7
When running C-c C-o and C-u C-c C-o on a link similar to the following:
file:~/Dropbox/org/test.org::*Test
I end up with a new frame being opened in both cases. C-u C-u C-c C-o opens the test.org file in my active emacsclient session. When changing the link to .../org/test.txt it still opens in a new frame, however it is unable to create the new file (I'm assuming I don't have .txt properly associated on my end, which is possible).
Testing with [mailto:test#test.org][test-mail]] also results in new frames by default.
Edit: The value for org-link-frame-setup is as follows (it is also the default since it is from emacs -q):
Its value is ((vm . vm-visit-folder-other-frame)
(gnus . org-gnus-no-new-news)
(file . find-file-other-window)
(wl . wl-other-frame))