I need the command that can open a file without closing emacs
I have tried C-X C-F
You were on the right track, but it's C-x C-f rather than the capitalized form C-X C-F which would imply the Shift key is held in addition to Control. So to be explicit, you want to hold Control down while pressing x and f in succession.
The C-x C-f sequence will invoke the find-file command under vanilla emacs, which lets you choose a file to open in a new buffer.
See also Emacs Manual Section 18.2 Visiting Files.
Emacs distinguishes between uppercase and lowercase letters.
Emacs doesn't pay attention to the actual pressing of the shift key but it pays attention to the receipt of the key combination, so if you press C-F it doesn't matter whether you physically pressed ctrl+shift+f or caps-lock followed by ctrl+f.
The exact combination is C-x C-f, without shift or caps-lock.
The right way is to hold your 'Ctrl' key and press 'x' followed by 'f', Make sure your capslock is off. and be in editing mode.
Related
How do I configure Emacs to keep track of the files visited and then allow me to navigate the chain back and forth? I'm not talking about mini-buffer or the cursor positions within the buffer, but rather the files themselves. I hope I got the terminology right of buffer vs file vs window.
ie if I visit
foo.c -> dired home -> readme.txt -> buffer-list
then by pressing some "back key" 3 times, file foo.c should open in the same (current) buffer I was in. Another way to think of it, is how navigation history works in Firefox - I want to browse files within the buffer like the webpages within a Firefox tab.
Use command previous-buffer which is bound by default to C-x <C-left> and C-x <left> (or nakedly, as I prefer to write them, C-x C-left and C-x left).
Similarly, to move in the other direction, there is command next-buffer, bound by default to C-x C-right and C-x right.
If you use library misc-cmds.el then you can remap the keys bound to these vanilla commands to repeatable versions previous-buffer-repeat and next-buffer-repeat.
(global-set-key [remap previous-buffer] 'previous-buffer-repeat)
(global-set-key [remap next-buffer] 'next-buffer-repeat)
Then you can just hold down right or left after hitting C-x, to quickly cycle through the buffers.
I am using Emacs 23.3 on Mac OS X Lion. How can I delete the selected text region with simple key typing—something like delete or C-d? This works on windows without setting anything specific. How can I implement that in Mac OS X Lion?
You need to enable delete-selection-mode and then it will work ;-)
Try M-xcua-mode. This will change a lot of things about the way Emacs behaves to fit the behavior of other GUI applications. For more information, see M-S-:(info "(emacs) CUA Bindings").
You can turn it on persistently with M-xcustomize-optionRETcua-mode.
If you mean "delete between the mark and the cursor," the normal keybinding for this in Emacs is C-w (Hold down control and press w).
To set the mark, use C-SPC (hold down control and press SPACE).
Selecting a text region and then deleting it is not very common to normal Emacs users. More frequently they use
C-k to delete entire lines at a time (or to the end of the current line)
M-z (press Esc then z) to "zap to char" which will delete all text to the next occurrence of any character
M-DEL (press Esc then DEL) to delete backwards a whole word at a time
and others.
In finding string in the current buffer, I know that we can use C-s or C-r, then you'll have the minibuffer prompt of what the string to be search. I know that we can use M-p or M-n to go to that prompt, but unfortunately emacs will display the previous search query.
I don't like using backspace to delete it, is there any key in which the prompt can be cleared from previous searches?
Thanks
Are you saying you want to change your search term while you are already in the process of searching?
A couple of simple options are:
Break out of the search first. I usually just do something which moves point, such as C-a. Then when you C-s again, the prompt will be blank (unless you type it twice, in which case it will search for the previous pattern again).
RET is isearch-exit, but that has a different effect with no pattern, and I prefer the consistency. You could also use C-g (isearch-abort), but you may need to type that repeatedly, depending on what happened up to that point.
ESCESCESC runs isearch-cancel which will reliably "Terminate the search and go back to the starting point", which may sometimes be preferable to C-a which will leave you on the line where you typed it.
You can edit the pattern on the fly with M-e, and then delete the whole thing with normal editing commands. After editing, type RET to continue searching for your newly-edited pattern.
Type C-sC-hC-h for the built-in help.
Try binding a key to the M-x search-forward command.
(global-set-key (kbd "C-s") 'search-forward)
This will automatically focus on the minibuffer and clear previous input.
I would like to know what are all the programmer-useful shortcuts that exists in emacs.
I come from a netbeans background and I am trying to make myself comfortable with emacs -text only environment. So I am looking at shortcuts for "refactoring" the code, "auto-completion", "go to definition" etc.
How can all these be achieved in emacs ? What are other programmer-useful shortcuts ?
I'll be using emacs basically for LAMP, javascript, C, C++.
ps - you can safely assume that I know how to open a file, save a file, navigate and whatever is in the tutorial in emacs.
For auto-completion, use etags with M-xtags-search or M-xetags-select-find-tag. I use macros often to do repetitive tasks. C-x(<string of useful tasks>C-x). Also, M-xalign-regexp to beautify the code and make it more readable.
You should find most of the most used features by Emacs users in this question's answers here at Stackoverflow.
Check this site
Some the important keybindings that are not there in the tutorial are:
Previous matching bracket: C-M-b (if it doesn't work, try ESC followed by C-b)
Next matching bracket: C-M-f (or ESC C-f)
Go to start of block: C-M-u
Go to end of block: C-M-d
Start of function: C-M-a
End of function: C-M-e
Outline mode: C-u 1 C-x $ (C-x $ to revert)
Newspaper mode: C-x 3 M-x follow-mode (especially useful with today's wide-screen monitors!)
Vertical Copy
Sometimes you will need to copy a vertical patch of data, e.g. one column in a table. First press C- where you want to start copying. Then go to the end of the column and press C-x r k. To paste the column press C-x r y. (If you don't want to delete original column, just press C-_ there once to restore it and then press C-x r y at target.)
To start, here is one :
Meta - / -> does code completion
M-x diff-buffer-with-file
M-x revert-buffer
When working with versioning (I use git), M-x diff-buffer-with-file is really useful. When you have a file open in a buffer in emacs, then you do a git checkout or some other action that touches that file, emacs will complain at you when you try to edit the buffer. M-x diff-buffer-with-file is helpful to see if you will break anything by keeping what's in the buffer. If something has changed and you want to grab the file from disc and put it in the buffer, do M-x revert-buffer.
If I click on File -> Close, it closes the buffer like I want, but doesn't list a key mapping. What is the key mapping?
You can use C-x k to kill current buffer. See Emacs Manual .
BKB has already given correct answer. Just wanted to add that C-h b lists the key bindings applicable in current buffer
Well, you can view the shortcut of any function with the Help command (C-h).
Press C-hw and then type the command name as you would in M-x mode.
For example (in your case):
Press C-hw
Type the name of the command: kill-buffer ( you can also use tab/space to autocomplete :) )
Press RET
Hope that helps :)
The question asks how to kill the current buffer. Use M-x kill-this-buffer. On my Emacs, it is mapped to s-k. Fewer keystrokes is better!
C-x k to kill the current buffer.
C-x 0 to close the current window.
C-x 1 to close every other window.