TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

My Emacs Productivity Tricks/Hacks

341 点作者 mycpuorg超过 5 年前

27 条评论

numlocked超过 5 年前
The one thing I consistently do in emacs that shocks my coworkers -- is running this (custom) function, that I call &quot;arrayify&quot;:<p><pre><code> (defun arrayify (start end quote) &quot;Turn strings on newlines into a QUOTEd, comma-separated one-liner.&quot; (interactive &quot;r\nMQuote: &quot;) (let ((insertion (mapconcat (lambda (x) (format &quot;%s%s%s&quot; quote x quote)) (split-string (buffer-substring start end)) &quot;, &quot;))) (delete-region start end) (insert insertion))) </code></pre> What it does: Given a list of strings separated by newlines (commonly, something copy-pasted from a table) like:<p><pre><code> josh sam jed C.J. toby </code></pre> You select the text, and run &quot;arrayify&quot;. You can optionally provide a quote character and, in about half a second, get to:<p><pre><code> &quot;josh&quot;, &quot;jed&quot;, &quot;sam&quot;, &quot;C.J.&quot;, &quot;toby&quot; </code></pre> This is incredibly useful for taking lists of IDs, or email addresses, or whatever, and transforming them for pasting into documents, or emails, or &quot;in&quot; clauses in SQL, etc.<p>It is <i>unbelievably</i> useful.
评论 #22132842 未加载
评论 #22132025 未加载
评论 #22133506 未加载
评论 #22132117 未加载
评论 #22131879 未加载
评论 #22132538 未加载
评论 #22132999 未加载
评论 #22138116 未加载
评论 #22135894 未加载
评论 #22131992 未加载
评论 #22132837 未加载
评论 #22133314 未加载
评论 #22136206 未加载
molteanu超过 5 年前
This is mostly a listing of packages and very known ones at that.<p>One of the best features I like is undoing regions. That is, if you know the approximate location of the text that you want to undo, you just select a region that contains that location and call undo. It can be used as a quick git alternative. Say you modify the buffer all over the place. If you want to undo some text that you&#x27;ve modified an hour ago but you did other modifications to the buffer in countless other places, you can undo just that region and you don&#x27;t have to go back throught the whole undo tree.<p>Another one that I&#x27;ve currently discoverd and I&#x27;m very excited about is yasnippet (the modern variant of abbrev). You can define a string that stands for an abbreviation for an expansion. Everytime you type that string, it is replaced by that expansion. The nice thing about yasnippet compared to abbrev is that, among others, you can specify where to leave the cursor after the expansion. One example: &quot;lt&quot; expands to (let ((_))), where _ is the cursor position after the expansion. This also saves typing of all the parantheses. Or &quot;mcar&quot; expands to (mapcar (lambda (_))). You can expand anything to anything, in short. With time, you can type less and faster.
评论 #22144959 未加载
评论 #22133604 未加载
评论 #22138840 未加载
jf超过 5 年前
I&#x27;ve used Emacs for decades and still feel like I&#x27;m barely scratching the surface.<p>What would really help me with articles like this one is more narrative on _why_ these particular modes are so useful. For example, it took me a long time to learn org-mode because I just didn&#x27;t know what to do with it! I feel like Helm is similar, I&#x27;ve tried it briefly, but I&#x27;m not sure if or how it would fit into my workflow.
评论 #22130696 未加载
评论 #22131147 未加载
评论 #22131102 未加载
评论 #22131734 未加载
评论 #22136116 未加载
评论 #22131639 未加载
why-el超过 5 年前
Another beautifully designed piece of Emacs software is magit, where the defaults are extremely sane. The package is self-documented and you can learn it all by typing ? anytime. Being able to git log the file you are in is also a huge plus.
评论 #22131824 未加载
评论 #22133405 未加载
评论 #22136440 未加载
评论 #22131468 未加载
评论 #22132513 未加载
aptidude187超过 5 年前
I used to think that Emacs is some weird editor with absurd keybindings, until I learned lisp and understood what makes it so special. Now Emacs (Spacemacs[0]) is my main driver.<p>[0] <a href="https:&#x2F;&#x2F;www.spacemacs.org" rel="nofollow">https:&#x2F;&#x2F;www.spacemacs.org</a>
评论 #22132076 未加载
评论 #22131967 未加载
Koshkin超过 5 年前
Emacs is the spaceship of typewriters. Whenever I try using it, I end up feeling like a centipede who began thinking about which leg it should move first.
anarchyrucks超过 5 年前
I installed Doom[0] and called it a day!<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;hlissner&#x2F;doom-emacs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hlissner&#x2F;doom-emacs</a>
评论 #22131215 未加载
评论 #22130698 未加载
评论 #22130387 未加载
098799超过 5 年前
Helm-projectile rant is well deserved. I&#x27;m often ashamed looking at my colleagues trying to find some file with a mouse in their big fat IDEs.
评论 #22134799 未加载
评论 #22131737 未加载
评论 #22130394 未加载
评论 #22132268 未加载
mapgrep超过 5 年前
&gt; All the packages were installed from Emacs package Manager. By running, `M-x list-packages` This should bring up a list of packages available in MELPA. Now, don’t worry if you don’t know what MELPA is, just think of it as a repository of all packages, as in, analogous to the Debian Package Repo in Debian&#x2F;Ubuntu distros.<p>Article seems to confuse MELPA with ELPA. MELPA is something you have to add via your init file. Not terribly hard to do, but just FYI for anyone who is actually using these tips from scratch.
jhoechtl超过 5 年前
I use Emacs every day. But only for org-mode which is fantastic.<p>Besides that I really really tried hard to love Emacs as my go-to editor. However I found no alternative for<p>decent CSV file support (like <a href="https:&#x2F;&#x2F;github.com&#x2F;chrisbra&#x2F;csv.vim" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chrisbra&#x2F;csv.vim</a> simply great!)<p>Inspecting large XML files with syntax highlighting and folding. VIM is also not the fastest here but at least 10 times faster (emacs SGML mode is a joke for xml files and forcing xhtml mode of web-mode is also not that great)<p>Maybe all my emacs doing was just wrong.
评论 #22133014 未加载
评论 #22132855 未加载
评论 #22133717 未加载
kwindla超过 5 年前
also tramp, for editing files on any machine you can ssh into ...<p><a href="https:&#x2F;&#x2F;www.emacswiki.org&#x2F;emacs&#x2F;TrampMode" rel="nofollow">https:&#x2F;&#x2F;www.emacswiki.org&#x2F;emacs&#x2F;TrampMode</a>
评论 #22130435 未加载
评论 #22130913 未加载
评论 #22135962 未加载
评论 #22145211 未加载
myrloc超过 5 年前
use-package would be an improvement upon most of the code snippets in the blog post. Loading packages without it these days feels like a sin.
评论 #22130815 未加载
cmrdporcupine超过 5 年前
I&#x27;m ashamed to say I&#x27;ve been using Emacs since 1992 but I have never been able to impress into my brain anything other than the minimal set of keystrokes to do basic editing. I feel like I need to be trapped on an island where the only thing I could do was learn emacs for a bit. There&#x27;s so much there to dig into.
评论 #22131303 未加载
评论 #22169340 未加载
arminiusreturns超过 5 年前
One of my favorites is creating a separate backup dir where all backup &quot;~&quot; files are created and versioned and rotated in and out etc at specific intervals, so I no longer get the random files in the dir I&#x27;m working in but can still go find backups if I mess something up.<p><pre><code> (setq backup-by-copying t backup-directory-alist &#x27;((&quot;.*&quot; . &quot;~&#x2F;.emacs.d&#x2F;bu&#x2F;&quot;)) delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t)</code></pre>
评论 #22135120 未加载
bitforger超过 5 年前
I&#x27;m extremely surprised to not see Spacemacs mentioned in the article or the comments. Spacemacs is, IMHO, the most sane and useful default configuration of Emacs. It is friendly to people switching from vim and includes all the packages listed in the article by default (as well as many more).<p>It has been my go-to editor for many years now; I highly recommend it.
arminiusreturns超过 5 年前
One of my favorites is creating a seperate backup dir where all backup &quot;~&quot; files are created and versioned and rotated in and out etc at specific intervals, so I no longer get the random files in the dir I&#x27;m working in but can still go find backups if I mess something up.
kleer001超过 5 年前
org f-ing mode<p>edit: actual package is called &quot;org-mode&quot;
评论 #22133953 未加载
评论 #22130391 未加载
warp超过 5 年前
What is the emacs equivalent of package.json?<p>(whenever I git clone my dotfiles on a new machine I usually have to comment out a bunch of stuff in my ~&#x2F;.emacs because it&#x27;s referencing packages which aren&#x27;t installed, and I forgot where I installed them from, what version, etc...)
评论 #22131612 未加载
评论 #22131574 未加载
评论 #22131659 未加载
评论 #22131744 未加载
评论 #22131648 未加载
评论 #22134653 未加载
rb808超过 5 年前
It seems a lot of people have used emacs for years and love it. I never saw the point of learning as it seemed cryptic. In 2020 is it worth putting the effort to learn now? I figure with vim and IDEs I dont really need it.
评论 #22131348 未加载
评论 #22131358 未加载
评论 #22131411 未加载
评论 #22131489 未加载
评论 #22131910 未加载
jaequery超过 5 年前
As a long time emacs user, I&#x27;m sad to say but I&#x27;ve become pretty content with Visual Code and I don&#x27;t think I&#x27;m going back. Ofcourse, took a lot of time customizing Code retaining all my emacs keybindings, etc.
评论 #22135312 未加载
m463超过 5 年前
a few I use:<p><pre><code> (defun shift-left (beg end) (interactive &quot;r&quot;) (shift-region beg end -1)) (defun shift-right (beg end) (interactive &quot;r&quot;) (shift-region beg end 1)) (global-set-key [A-M-right] &#x27;shift-right) ;; &gt;&gt; shift every line of region (global-set-key [A-M-left] &#x27;shift-left) ;; &lt;&lt; (and region remains highlighted) (global-set-key &quot;\M-+&quot; &#x27;text-scale-increase) (global-set-key &quot;\M--&quot; &#x27;text-scale-decrease) (global-set-key &quot;\M-=&quot; (lambda () (interactive) (text-scale-set 0)))</code></pre>
hellofunk超过 5 年前
the others I cannot live without:<p>neo tree<p>winner mode<p>god mode (I use instead of evil mode)<p>avy (visually jump to any char on the screen)<p>undo-tree (really neat, though I don&#x27;t use it as much any more)
评论 #22130385 未加载
评论 #22130618 未加载
评论 #22130424 未加载
评论 #22136161 未加载
评论 #22134078 未加载
rcgorton超过 5 年前
emacs as a binary editor: useful. Any other uses: counter-productive. I&#x27;ve (painfully) watched some amazingly gifted researchers&#x2F;engineers using it, and saw them waste about 50% of their attention trying to use it. Emacs is not an editor, it is an OS with non-obvious semantics.
rntksi超过 5 年前
If the author, @mycpuorg, is reading this comment: please, PLEASE, do write about your mu4e configuration.
评论 #22131005 未加载
antoineMoPa超过 5 年前
My favorite these days is a package called find-file-in-project. Ideal for navigating large projects.
评论 #22134343 未加载
tomThom超过 5 年前
I would be productive if there were an emacs that weren&#x27;t a parenthesis hell and slow as molasses. I hope there&#x27;s is a lumacs
cletus超过 5 年前
Whenever I hear about or see the .vimrc and .emacs files people create, maintain and constantly modify to me this just looks like the perfect example of a sunk cost fallacy.<p>IDEs are usually dismissed by many such people since you can (allegedly) do the same in vim&#x2F;emacs but to me this seemed crazy as I&#x27;d see people spend hours configuring plugins, writing Lisp and whatever to save them on some task they&#x27;d get for free with a right click in IntelliJ.<p>I really do think people completely underestimate how much time they have and will invest in such endeavours. I mean if this makes you happy or you like this tinkering, by all means be my guest, but I&#x27;ll take a hard pass.
评论 #22132452 未加载
评论 #22132938 未加载
评论 #22134196 未加载
评论 #22132768 未加载
评论 #22133738 未加载
评论 #22143956 未加载