Emacs as the Ultimate LaTeX Editor
piotrkazmierczak.com
piotrkazmierczak.com
Just as a FYI to people on weaker hardware.
xptemplate has a bazillion features, and yasnippet is primitive in comparison. Just a simple example is that in xptemplate (and probably any respectable snippet plugin in vim) you can type a part of a snippet name, hit TAB, and it will expand the snippet whose partial name you typed (assuming there's no exact match). In yasnippet, you have to type out the full snippet name before it can be expanded. This is pretty annoying, especially for long snippet names.
There are tons of other examples of far more advanced functionality, such as a variety of snippet repetition and embedding features.
This comparative lack of features in yasnippet is pretty surprising, because emacs extensions are usually very feature rich, and everyone seems to love yasnippet. But I think that's because most emacs users don't know what they're missing.
And before someone says it, yes, I know yasnippet gives you the ability to embed eLisp code in it, so I could potentially write all the functionality I need myself. But that's really beside the point. I'm talking about built-in features, not the ability to code up the features myself.
Yes, you can do that as well. See the list of expansion methods with screenshots inside: https://capitaomorte.github.io/yasnippet/snippet-expansion.h.... You may interest in minibuffer prompting.
You already have a built-in template system in Emacs called Srecode that allows you to program your templates: http://cedet.sourceforge.net/srecode.shtml
According to the homepage, "the core template text is based loosely on Google ctemplate".
As for SRecode, that looks interesting but its documentation is impenetrable. Someone seriously needs to write a bunch of tutorials for that thing. Otherwise, I can't really tell if it can do what xptemplate is capable of or not.
I found some comments from SRecode's author suggesting that it's intended for different uses from yasnippet:
"Thus, the audience for yasnippet and SRecode is quite different.
Of course you could do yasnippet like things with SRecode if someone
took the time to improve the field-editing feature in SRecode, but
that has not been my focus."[1]
[1] - http://emacs-fu.blogspot.com/2010/09/interview-with-eric-lud...You can have a look at a sample template: https://github.com/emacsmirror/cedet/blob/f72ebbc52785013280... . Srt file has syntax highlighting in Emacs.
C-c C-e means "give me a new environment"
In general, if you want flawless R support in certain blocks of text (as in a .Rnw file) in between LaTeX blocks that are fully connected to AucTeX, well... you're out of luck. And Vim... Vim-R-Plugin is useful, but it's sort of a painful hack to use tmux just to get R and Vim to talk (and I'm saying this even though I love Tmux).
Vim has YouCompleteMe, which is smooth as silk compared to Emac's options (which are painful and poorly integrated, especially with clang). But some lower-level issue in Vim causes this constant error message in Vim whenever YouCompleteMe uses clang — bloody annoying. So overall, both editors have huge issues that would require serious overhauls or tedious bug fixing in various modes. Sure, Emacs does AucTeX better, but until it does everything better (or Vim does everything better) it's a flawed editor. Both are flawed editors. But sadly everyone thinks the best course of action is to start fresh — which usually creates a feature-poor flawed editor on a new shiny foundation, that fails to attract developers because it's feature poor. (apologies for ranting -- jetlag).
Are the vi keybindings really better for your RSI? I've heard different stories. For example,
http://changelog.complete.org/archives/661-so-long-vim-im-re...
There's a new ergoemacs mode that I haven't tried yet: http://ergoemacs.org
Personally, I spend more time using IntelliJ, Xcode, and Sublime these days, but recently I started using Emacs again for a bunch of .org stuff.
By the way, there's an Emacs StackExchange which will hopefully make emacs more accessible.
http://emacs.stackexchange.com/questions/2671/how-can-i-get-...
Or Emacs's fantastic support for communicating with REPLs in many interpreted languages.
You can execute any shell command asynchronously while doing other things inside Emacs. You can even compile with beautiful output, in terminal: http://tuhdo.github.io/static/c-ide/compilation-compile.gif
Or built-in GDB integration, also asynchronous: http://tuhdo.github.io/static/c-ide/gdb-many-windows.gif.
Another GDB screenshot: https://flic.kr/p/6FW7Q7.
And Emacs officially supports asynchronous IO, while in Vim it's a hack from Vim Script.
"Threading. This has been an irritant for me for years. Emacs
blocks all windows when you're doing computation in any window.
It's an operating system, but not enough of an operating system.
I myself will run three instances of Emacs to get around this.
I'm slurping in my email and I can't do something at the same time
because it's off in space slurping in my email. It's going off and
doing some extended computation and I can't go in another window and
do anything else at the same time. ... If it's doing extended
computation and a lot of file IO and talking to the network, it
blocks you. There's not more than one thread there."
There's also this[2] discussion of lack of threading in Emacs on the Emacs Wiki.Neither adds much to the discussion.
Which isn't to say that posts such as this can't provide value. I've been using vim and its antecedents for over a quarter century, as well as well over another editors and authoring tools (closer to two dozen). Including a few forays into emacs-land.
I find discussions of tools useful, and have added a few to my own suite in the past year. Most recently vim-outliner, an outlining plug-in for vim, also Pandoc, and in the past two years, for the first time after considering it for a long time, LaTeX.
Describing WHY an editor or tool suits you, or SPECIFIC features it has or offers, is far more useful.
It will also make the discussion here hugely more valuable than just pointing people at vim or emacs (again). Both are pretty easy to find without that help.
Providing reasons and specific benefits -- much more valuable.
For example: <leader>ll will compile your document, multiple times if necessary, and show you warnings/errors in a new window, letting you hit enter on each to jump to the line. Lots of helpers for inserting environments, items, packages, too!
But if you're used Emacs just for auctex, more power to you for harnessing the power of two awesome editors!
I would be interested to hear what AucTEX provides that the above combination can't.
(These may not be standard bindings - my .emacs is a horrible mess of legacy code dating back to a pre-git world.)
\begin{itemize}
\item item1
\item item2
\end{itemize}
I could probably convince vim to do that, but auctex does it out of the box with no additional configuration required.Likewise, I could probably set makeprg to latexmk or rubber or some other DWIM script, but that ought to Just Work as easily as auctex's C-c C-c, and shouldn't require a pile of configuration.
I haven't even found a way to bind <A-Enter> in vim's insert mode, because vim can't distinguish that from <Esc><Enter>.
item<TAB>item1<TAB><TAB>item2<C-d>
results in exactly the same thing. True, I had to spend 5 minutes writing a snippet to do that,[1] but that was because the default snippet behaved differently (though arguably just as intuitevely).xptemplate comes with a bunch of LaTeX snippets (and ones for about 50 other languages), but it's easy enough to add more yourself, especially when the desired behavior is as simple as you describe. It gets trickier when you have lots of nested snippets, menus, conditionals, etc. But the tools are there as features, and you don't have to write the features themselves yourself, just use them.
As for latexmk, depending on how complex your needs are, you may not have to configure it, just run it. A "latexmk -pdf foo.tex" will probably do what you want. Configuring it or using other/more options give you more control, which is a good thing. AucTeX, by the way, has a latexmk plugin.
[1] - It would have gone a lot faster had it not been a couple of years since I wrote an xptemplate snippet.
I don't mind configuring something when I actually want to change its behavior, but I'm a big fan of sensible and helpful defaults that Just Work. I'm not complaining that there isn't a vim mode that works exactly like auctex out-of-the-box; I'm annoyed that there doesn't seem to be one that has equivalent functionality out-of-the-box. I could reinvent it using templates/snippets, but I didn't have to do so with auctex.
> As for latexmk, depending on how complex your needs are, you may not have to configure it, just run it. A "latexmk -pdf foo.tex" will probably do what you want.
I understand that I wouldn't have to configure latexmk (or rubber, or any number of other DWIM scripts for LaTeX), but I'd still need to configure vim to use one of them and have a convenient keybinding for them. I'd also prefer not to rely on an external script; I'd rather have something built into vim and configurable within vim.
In a discussion on Latex Editors, I find it surprising how it was not mentioned even, so far.
* It has code completion
* File and document navigation is easy thanks to tree view
* It works out of the box, no dependencies other than TeX required
It would rock harder is someone(tm) implemented a visual version of LaTeX, for small quick documents and for newbie accessibility.
If you're doing quick small documents, Markdown and Pandoc may well be a better fix for you.
A useful mode for working with LaTeX (or other tagged documents) is to have a build system which watches your source, re-builds it as you edit it, and a viewer which updates as the generated PDF is refreshed.
You can do this with LaTeX, Markdown + Pandoc, or numerous other systems. It's quite powerful.