Rectangle 27 347

With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note taking, organisation, games, programming, shell access, file access, listening to music, web browsing. It takes weeks and weeks till you will be happy with it and then you will learn new stuff all the time. You will be annoyed when you don't have access to it and constantly change your config. You won't be able to use other peoples emacs versions easily and it won't just be installed. It uses Lisp, which is great. You can make it into anything you want it to be. (anything, at all)

With vim, it's almost always pre-installed. It's fast. You open up a file do a quick edit and then quit. You can work with the basic setup if you are on someone else's machine. It's not quite so editable; but it's still far better than most text editors. It recognises that most of the time you are reading/editing not typing and makes that portion faster. You don't suffer from emacs pinkie. It's not so infuriating. It's easier to learn.

W.r.t not having it available: I suggest putting your .emacs and .emacs.d in a source control repo, and so getting your perfect Emacs setup is simply a matter of a checkout.

Both emacs and vim can suffer from what is described above: both can be configured to the point where they are unrecognizable compared to their vanilla forms. Also, I second the use of a vcs.

What systems do you work on, @Radu? I've never seen a real-life system in the 2010s that had real vi instead of vim aliased to that.

Maybe Vim is easier to learn than Emacs, but it's incredibly confusing the first time you start it up if you have no previous experience with it! I had to use google to be able to close it down, and still had to try several times to get it right.

Never underestimate the "pre-installed" perk of VIM: it's almost always available wherever you go, and its usable with little/no customization. I use it all the time when sshing to other machines. This is why I learned it firstthat, and because my friends knew VIM and could help me. (Don't underestimate friends' support either!)

Differences between Emacs and Vim - Stack Overflow

vim emacs
Rectangle 27 41

I type M-x delete-region quite often, but you can bind it it to a key.

With Delete Selection Mode in newer versions of Emacs you don't have to type a command just start typing:

By default, text insertion occurs normally even if the mark is activefor example, typing a inserts the character a, then deactivates the mark. Delete Selection mode, a minor mode, modifies this behavior: if you enable that mode, then inserting text while the mark is active causes the text in the region to be deleted first. Also, commands that normally delete just one character, such as C-d or DEL, will delete the entire region instead. To toggle Delete Selection mode on or off, type M-x delete-selection-mode.

Also, with the latest version of Emacs, you don't even need to bind delete-region to a key because Backspace does that now. Backspace deletes the selected region instead of killing it, in other words, Backspace erases the selected text without saving/pushing it to the kill ring. This is because the value of delete-active-region is t unless you customize it to some other value.

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 41

I type M-x delete-region quite often, but you can bind it it to a key.

With Delete Selection Mode in newer versions of Emacs you don't have to type a command just start typing:

By default, text insertion occurs normally even if the mark is activefor example, typing a inserts the character a, then deactivates the mark. Delete Selection mode, a minor mode, modifies this behavior: if you enable that mode, then inserting text while the mark is active causes the text in the region to be deleted first. Also, commands that normally delete just one character, such as C-d or DEL, will delete the entire region instead. To toggle Delete Selection mode on or off, type M-x delete-selection-mode.

Also, with the latest version of Emacs, you don't even need to bind delete-region to a key because Backspace does that now. Backspace deletes the selected region instead of killing it, in other words, Backspace erases the selected text without saving/pushing it to the kill ring. This is because the value of delete-active-region is t unless you customize it to some other value.

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 34

You can use M-y after C-y to insert previous item from the kill ring, or use browse-kill-ring package.

As for the second question, see DeleteSelectionMode.

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 33

You can use M-y after C-y to insert previous item from the kill ring, or use browse-kill-ring package.

As for the second question, see DeleteSelectionMode.

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 97

Vim is not a shell. And it does not communicate well with subprocesses. This is nearly by design, where as in Emacs, these elements are included by design. This means that some stuff, like embedding a debugger or a intepreter (yielding a sort of IDE), is difficult in Vim.

Also, Emacs shortcuts are mainly accessed through modifiers, and obviously the Vim interface is famously modal, giving access to an absurd amount of direct keys for manipulation.

Emacs used to be the only editor of the two that was proagrammable, and while Vim has a lot of weird levels to it's programmability, with the addition of Python and Ruby bindings (and more, I forget), Vim is also programmable in most ways you'd care for.

I use Vim, and I'm fairly happy with it.

Differences between Emacs and Vim - Stack Overflow

vim emacs
Rectangle 27 109

Just for completeness, since some folks may visit this page thinking they will get an answer for the "save as" feature of Emacs, that's C-x C-w for an open file.

File > Save as...

Not quite "save as", since the file you are editing will still be the original one.

@asmeurer You are wrong! After saving, you will be editing the new file.

Again, why isn't there a feature to downvote comments?!

Perhaps asmeurer meant, "the file you [were] editing will still [exist]". Then, is that correct? I would check, but then, you cannot downvote my comment, hahaha.

How do I rename an open file in Emacs? - Stack Overflow

emacs
Rectangle 27 79

  • better as a simple editor (fewer keys required for simple tasks)
  • also extensible in python, ruby
  • non modal by default (most of today's editors have taken this approach). Though there is evil-mode which emulates vim behavior.
  • more powerful language for extending it (elisp is a full blown language, and in emacs you can practically redefine everything; while in vim you cannot redefine build in functions of the editor. On the downside, vimscript is relatively similar to today's dynamic languages while elisp doesn't resemble pretty much anything)
  • excellent support for GNU tools (the bunch of them)

Personally, I prefer vim - it is small, does what it's supposed to do, and when I wish a full blown IDE I open VS. Emacs's approach of being an editor which wants to be an IDE (or should I say, an OS), but is not quite, is IMHO, outdated. In the old days having a email client, ftp client, tetris, ... whatnot in one package (emacs) made some sense ... nowadays, it doesn't anymore.

Both are however a topic of religious discussions among the programmer and superuser community users, and in that respect, both are excellent for starting flame wars if put in contact (in the same sentence / question).

"better as an editor" is pretty vague. I'd be interested in seeing reasons why.

@Allen - What is vague in it ? I rarely meet users of both vim and emacs, who have a problem with that statement. Even hardcore emacs users usually accept it as a fact. Have you used both editors ? I believe it is relatively obvious that vim has an advantage in the aspect of text editing features.

I am incredulous that anyone would accept that as a fact. As a long time user of both emacs and plain VI, I have used vim a few times - but "better as an editor" has to go to emacs in my mind if for no other reason than a far wider selection of major and minor modes to help you as you type.

Vim is better as an editor because manipulating text requires less movement of your hands and fingers than emacs, at least that is my experience.

Differences between Emacs and Vim - Stack Overflow

vim emacs
Rectangle 27 19

I have had the same issue. The closest thing I've got so far is to just make a small function that's essentially:

(defun ruthlessly-kill-line ()
  "Deletes a line, but does not put it in the kill-ring. (kinda)"
  (interactive)
  (move-beginning-of-line 1)
  (kill-line 1)
  (setq kill-ring (cdr kill-ring)))

Why not just (delete-region (line-beginning-position) (line-end-position))?

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 19

I have had the same issue. The closest thing I've got so far is to just make a small function that's essentially:

(defun ruthlessly-kill-line ()
  "Deletes a line, but does not put it in the kill-ring. (kinda)"
  (interactive)
  (move-beginning-of-line 1)
  (kill-line 1)
  (setq kill-ring (cdr kill-ring)))

Why not just (delete-region (line-beginning-position) (line-end-position))?

Emacs: how to delete text without kill ring? - Stack Overflow

emacs
Rectangle 27 423

If you've ever been saved by an Emacs backup file, you probably want more of them, not less of them. It is annoying that they go in the same directory as the file you're editing, but that is easy to change. You can make all backup files go into a directory by putting something like the following in your .emacs.

(setq backup-directory-alist `(("." . "~/.saves")))

There are a number of arcane details associated with how Emacs might create your backup files. Should it rename the original and write out the edited buffer? What if the original is linked? In general, the safest but slowest bet is to always make backups by copying.

(setq backup-by-copying t)

If that's too slow for some reason you might also have a look at backup-by-copying-when-linked.

Since your backups are all in their own place now, you might want more of them, rather than less of them. Have a look at the Emacs documentation for these variables (with C-h v).

(setq delete-old-versions t
  kept-new-versions 6
  kept-old-versions 2
  version-control t)

Finally, if you absolutely must have no backup files:

(setq make-backup-files nil)

hey but it is creating backups with a name like this one !home!svradmin!foo~ and I cannot open the file

why use backups? why not use git/mercurial? good version control systems and programming methodologies should trump individual file backup by the editor

@vol7ron : The backups are for when you are editing something not under version control - like a config file or something quick and dirty that you haven't gotten around to putting into version control yet. Then, when you haven't been doing what you ought to, the editor saves your neck.

@vol7ron - That's just wrong. You shouldn't be putting crap into revision control that you don't want to keep. It just makes finding the important stuff way harder. Instead, use your editor backups for what they are good for (backing up changes in case of emergency) and revision control for what its good for (keeping important versions of your software and facilitating team development). Use the right tool for the job.

"Backup files add so much overhead and almost no value": isn't that judgmentalism?

How do I control how Emacs makes backup files? - Stack Overflow

emacs
Rectangle 27 10

You can find detailed description of emacs & version control integration on my site. I'm also working on article about using Emacs as Development Environment for many languages - C/C++, Java, Perl, Lisp/Scheme, Erlang, etc...

Using Emacs as an IDE - Stack Overflow

emacs ide development-environment slime
Rectangle 27 95

Very strange that the very convenient M-x eval-buffer is not mentioned here. It immediately evaluates all code in the buffer, its the quickest method, if your .emacs is idempotent. share|improve this answer edited May 18 '15 at 16:53 answered Nov 17 '14 at 18:37 Peter 25.5k31118164

@mike : not me. "Given a, b is true" meant for me, "if a, b is true" , but I can see what you mean. I change given to if for more clarity.

.emacs

@mike toggling settings from the default...

I would have thought this to be the first suggestion.

How can I reload .emacs after changing it? - Stack Overflow

emacs
Rectangle 27 41

The biggest thing about learning how to use Emacs is ... (drumroll please) learning how to use Emacs.

Okay, okay, okay. It's a silly answer, and it's a tautology, but it's true. If you start up Emacs, and think to yourself "How could I find every instance of the word 'foobar' in my source tree?" the worst thing you could do is hit Alt + Tab and visit Google.

Learning the help system and how it works is the best thing you can do. It's so nice to just hit C-h a find, and suddenly get all the information you need, right at your fingertips.

The next best thing you could do is install a wonderful little package called Icicles which has some seriously groovy completion functions. After you get it installed, just know that anytime the minibuffer is asking for some kind of input, you can now use regular expressions.

How would this apply to finding every file in your source tree? Well, you'd hit M-x, and then type "find". After that, you could hit (for instance) Shift + Tab and Icicles would kick in, finding every command that prefixes with "find". Alternatively, you could do M-x .find. and it would give you any command with find in it.

Build a cheat sheet. Just keep a saved buffer somewhere that has all of the keyboard shortcuts you use frequently in it. Remove the ones that you know off by heart, and pick up new ones. In most cases when you do a M-x command, the message buffer will tell you what the keyboard shortcut was for that command (if there was one).

Steven Huwig's idea of using some killer applications is a good one. Emacs is easier to use when you want to use it. For me, it was Planner Mode. (I've just moved to Org-mode, and it's even better.)

+1, but C-h c maps to describe-key, which isn't what you meant I don't think when you said "C-h c find". "C-h a find" maybe?

Good advice (learning the help system, creating a cheatsheet - in emacs!) +1.

See, in particular, this page about using Icicles to help you learn Emacs: EmacsNewbieWithIcicles.

How to quickly get started at using and learning Emacs - Stack Overflo...

emacs
Rectangle 27 41

The biggest thing about learning how to use Emacs is ... (drumroll please) learning how to use Emacs.

Okay, okay, okay. It's a silly answer, and it's a tautology, but it's true. If you start up Emacs, and think to yourself "How could I find every instance of the word 'foobar' in my source tree?" the worst thing you could do is hit Alt + Tab and visit Google.

Learning the help system and how it works is the best thing you can do. It's so nice to just hit C-h a find, and suddenly get all the information you need, right at your fingertips.

The next best thing you could do is install a wonderful little package called Icicles which has some seriously groovy completion functions. After you get it installed, just know that anytime the minibuffer is asking for some kind of input, you can now use regular expressions.

How would this apply to finding every file in your source tree? Well, you'd hit M-x, and then type "find". After that, you could hit (for instance) Shift + Tab and Icicles would kick in, finding every command that prefixes with "find". Alternatively, you could do M-x .find. and it would give you any command with find in it.

Build a cheat sheet. Just keep a saved buffer somewhere that has all of the keyboard shortcuts you use frequently in it. Remove the ones that you know off by heart, and pick up new ones. In most cases when you do a M-x command, the message buffer will tell you what the keyboard shortcut was for that command (if there was one).

Steven Huwig's idea of using some killer applications is a good one. Emacs is easier to use when you want to use it. For me, it was Planner Mode. (I've just moved to Org-mode, and it's even better.)

+1, but C-h c maps to describe-key, which isn't what you meant I don't think when you said "C-h c find". "C-h a find" maybe?

Good advice (learning the help system, creating a cheatsheet - in emacs!) +1.

See, in particular, this page about using Icicles to help you learn Emacs: EmacsNewbieWithIcicles.

How to quickly get started at using and learning Emacs - Stack Overflo...

emacs
Rectangle 27 6

The biggest difference for me in choosing to use emacs over vim was the built in gdb support in emacs. Vim doesn't have this included in it's default distribution and the project there for integrating gdb and vim was nearly impossible to get working with MacVim

I used Vim for editing, and Xcode for debugging, it's less than ideal but doable..

Differences between Emacs and Vim - Stack Overflow

vim emacs
Rectangle 27 120

The key point is to tell emacs to insert whatever you want when indenting, this is done by changing the indent-line-function. It is easier to change it to insert a tab and then change tabs into 4 spaces than change it to insert 4 spaces. The following configuration will solve your problem:

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

An important function of each major mode is to customize the key to indent properly for the language being edited.

The indent-line-function variable is the function to be used by (and various commands, like when calling indent-region) to indent the current line. The command indent-according-to-mode does no more than call this function.

The default value is indent-relative for many modes.

If the previous nonblank line has no indent points beyond the column point starts at, `tab-to-tab-stop' is done instead.

Just change the value of indent-line-function to the insert-tab function and configure tab insertion as 4 spaces.

I have the same problem as the OP, your solution does not work for me.

Please, elaborate further. Do you mean that using the above lines as the only content of your .emacs and calling "M-x indent-according-to-mode" won't insert 4 spaces?

@BruceBarnett I am in text mode and these instructions still don't work.

indentation - Set 4 Space Indent in Emacs in Text Mode - Stack Overflo...

emacs indentation
Rectangle 27 233

Oh. My. Word. Just what I was looking for. Many thanks huaiyuan.

Yes, follow-mode works with any number of windows.

Emacs - Multiple columns one buffer - Stack Overflow

emacs
Rectangle 27 281

Yes, with dired mode, you can:

  • C-x C-j (dired-jump to the name of the current file, in Dired)
dired-do-rename
C-x k RET

The rename is equivalent to a shell mv, but it will also update any open buffers.

That's not directly renaming the current file.

C-x b and you're back in the original buffer. You could write an Elisp function to do it, but I doubt you'll save many keystrokes with it.

Also, rather than C-x b, you can press C-x k to be back in the original buffer.

Thanks for this answer. It's simpler than adding functions. As for "That's not directly renaming the current file", it seems to do just that. The file is renamed on the disk and the buffer.

The C-x C-j is not bound by default for me. Doing M-x load-library RET dired-x RET first makes it bound.

How do I rename an open file in Emacs? - Stack Overflow

emacs
Rectangle 27 258

You can use the command load-file (M-x load-file, then press return twice to accept the default filename, which is the current file being edited).

You can also just move the point to the end of any sexp and press C-xC-e to execute just that sexp. Usually it's not necessary to reload the whole file if you're just changing a line or two.

Keep in mind that this may not always do exactly what you think it does. If you have variables whose contents are flopped( ie setting a boolean to it's opposite) then the behavior won't be the same as loading the file.

Any side-effects in general are likely to break the desired behavior: loading files, etc.

When I do this, I get the message: load-with-code-conversion: Symbol's value as variable is void: n

Instead of moving point behind a defun or defvar, you can also leave it inside the declaration body and type C-M-x. Very handy.

How can I reload .emacs after changing it? - Stack Overflow

emacs