3 ms·
So what kind of stuff do you program inside of it? What kinds of problems do you solve? I mean, I've never really felt the need to program an add-on to text ed
by crazygringo 14y ago
So what kind of stuff do you program inside of it? What kinds of problems do you solve?
I mean, I've never really felt the need to program an add-on to text editor. I download syntax highlighting packages, and there are common macros like "remove trailing whitespace" already installed. Keyboard shortcuts can be changed in lots of editors and OS's. In the past, I've definitely been upset that a particular editor didn't support a particular feature, but by now they've progressed enough that I don't really feel that anymore.
- heretohelp 14y agohttps://github.com/bitemyapp/dotfiles https://github.com/bitemyapp/dotfiles Highlights: a Python IDE with refactoring, inference, search, etc. Some hacks for TRAMP which lets me remotely edit content on arbitrary servers transparently. A Python repl. A generic compliance checker for Python code. An undo module that presents undo/redo history as a visible tree that you can traverse arbitrarily. A git client that has some EXCELLENT features. A function to dynamically reload my environment. A macro for my python debugger injector. Code to unhtml HTML content and a whitespace cleaner-upper. An interactive environment to experiment with and test regex. A mode for CSS that highlights hex-values with the colors they represent, making their properties visual. An interactive HTTP REST client interface for testing HTTP APIs. A clone of hacker-typer in elisp. Modes for clojure, erlang, haskell, rust, etc. And a nyan-cat for my progress bar.
- Wilduck 14y agoI probably define ad-hoc macros 10-15 times a day These are for tiny things that save me a minute or two each time I use one. More than the time savings, though, is the sanity savings. I've it's rare now that I do any sort of repetitive editing task. Also, you don't have to actually program the editor yourself to reap the benefits of a programmable editor. Let's be honest, most modern editors have mostly overlapping functionality. However, one of the benefits of emacs being programmable is that it's self documenting. I can find out how to capitalize a word problematically without having to go to google by using `M-x apropos RET capitalize RET`.
- draebek 14y agoLooking through my .emacs for things I, personally, have written: - A little hook to use an external Python program (cheating, I know) to look up the definition of the word under the cursor in the OS X dictionary. - Several customizations for org-mode, which I use for anything where I want to make an outline, including and especially to-do lists. - I actually still have some code to do "smart tabs" (http://www.emacswiki.org/SmartTabs http://www.emacswiki.org/SmartTabs) for some modes, though that's now probably obsolete if I would only configure up the code mentioned in that list for C modes. (I'm already using it for e.g. Python code.) - Some configuration for LaTeX editing, like packages AUCTeX doesn't know about, converting words/phrases into \gls (glossary) references. I actually have less custom stuff in .emacs than I thought. Having a programmable editor does mean that it's relatively easy for other people to write some really useful stuff which I then get to use. I have some local modifications to other people's packages which I don't have time to enumerate right now.
- mechanical_fish 14y agoI can't answer your whole question or we'll be here all day. Here's one important example, which has the advantage of applying in vim as well as emacs: "Common" macros are the least interesting. The most interesting macros are the ones with no name, the one-time ones that you build on the fly. You have a file with ten thousand lines of: foo.rb bar.rb baz.rb … … [9997 more lines like these] and you need to turn the file into something like this: // Run the foo command def foo() end // Run the bar command def bar() end // Run the baz command def baz() end … [9997 more blocks like these ] That's 56 keystrokes in emacs: You record a macro that transforms one line appropriately, then execute it 9999 more times, all on the fly in about twenty seconds.
- TorKlingberg 14y agoFor that I would probably have used a regex search and replace in any decent editor, or perhaps a Perl one-liner. cat file | perl -p -e 's-\s(.)\.rb-// Run the $1 command\ndef $1()\nend\n-'
- sophacles 14y agoAs a heavy user of regex one liners, I agree in this case, but as a heavy user of vim, there are lots of times when a macro can be recorded and run over a file long before a proper regex can be constructed, particularly in multi line settings, or those things that would require heavily nested backrefs.
- sophacles 14y agoFor completeness - same task in vim: start recording a macro: qa Then enter this sequence of keystrokes[1]: 0veyO// Run the ^R" command<esc>j0f.C()<cr>end<cr><esc> Then exit macro recording with: q Then enter the command: :g/.rb$/ norm @a to run the macro on every line ending with .rb (allowing comments in the input, just because (of course it would be nice to make that regex in :g look for "lines that start with comments" and ignore them explicitly)). If I counted right, thats 57 keystrokes, and I might have been slightly inefficient in my usage, of course, if that one keystroke is part of a command my fingers just do, there is no effective difference :) [1] I know it was exactly that sequence because I just pasted the macro buffer, which of course can then be edited, saved back to the buffer and run in edited form.
- mechanical_fish 14y agoI can't answer your whole question or we'll be here all day. Here's one important example, which has the advantage of applying in vim as well as emacs: "Common" macros are the least interesting. The most interesting macros are the ones with no name, the one-time ones that you build on the fly. You have a file with ten thousand lines of: foo.rb bar.rb baz.rb … … [9997 more lines like these] and you need to turn the file into something like this: // Run the foo command def foo() end // Run the bar command def bar() end // Run the baz command def baz() end … [9997 more blocks like these ] That's 56 keystrokes in emacs: You record a macro that transforms one line appropriately, then execute it 9999 more times, all on the fly in about twenty seconds. I did this, then put the results into a buffer ('kmacro-edit-macro') so that I could paste the macro here: C-x ( ;; kmacro-start-macro C-a ;; move-beginning-of-line C-s ;; isearch-forward .rb RET ;; newline C-k ;; kill-line C-SPC ;; set-mark-command C-a ;; move-beginning-of-line C-x C-k ;; kill-region // Run the C-y ;; yank command RET ;; newline def C-y ;; yank () RET ;; newline end RET ;; newline C-n ;; next-line C-x ) ;; kmacro-end-macro (49 keystrokes so far) C-u 9999 C-x e ;; run the above macro 9999 times This isn't all that special. If your editor can't do this, I suggest finding one that can. Emacs or vi are good choices. I haven't had to change editors since adopting emacs twelve years ago.
- hell0_th3r3 14y agowell instead of getting upset, emacs users can fix their own problems if they so wish
- heretohelp 14y agoYep. We're not dependent on any commercial entities to fix our tools. We sharpen our tools ourselves.
- justinhj 14y agoThe thing is once you can code in emacs, and even when you can use the keyboard macro utility, you constantly find little time saving ways to use it. At first though they're not even time saving, they take longer. Anyhow some examples: I have a function for my work log which gets the date, figures out the previous Monday's date and dumps a formatted weekly log for me to fill out. I wrote an entire budget tracking application which generates a forecast and dumps it to a csv file Wrote a utility to mark and optionally delete duplicate files in a dired buffer Convert a windows path name to a cygwin one Functions to add local sales tax and remove local sales tax, same for tips. Perforce source control, helpers to do blame functionality and other stuff that benefits from pulling Perforce output into a buffer The most used feature would be keyboard macros which are endlessly useful for any repetitive editing task, which can show up unexpectedly at any point of the day Occasionally have to write throw away custom code to create some boiler plate code, such as turn the API documentation for some errors into a C++ array of structures that can be manipulated in code Full client for Redis
- irahul 14y ago> So what kind of stuff do you program inside of it? What kinds of problems do you solve? It's not always about programming. It's about configuring and extending to suit it to your problem. Pylinting and running python code. ,c(mapped to :make, not shown here) to pylint(not need as I run syntastic but still), ,x to run augroup python au! autocmd FileType python nnoremap<buffer> ,x :w<CR>:!/usr/bin/env python % <CR> autocmd FileType python setlocal nosmartindent autocmd FileType python setlocal makeprg=pylint\ --reports=n\ --output-format=parseable\ %:p autocmd FileType python setlocal errorformat=%f:%l:\ %m autocmd BufRead python setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m autocmd FileType python setlocal path+=$PYTHONDIRS augroup end ERB and Jinja2 shortcuts. \1 for <% {cursor_here} %>, \2 for <%= {cursor_here} %> etc inoremap \1 <%<Space><Space>%><Esc>2hi inoremap \2 <%=<Space><Space>%><Esc>2hi inoremap \3 {%<Space><Space>%}<Esc>2hi inoremap \4 {{<Space><Space>}}<Esc>2hi A mini calculator function, lots of snippets, some saved macros etc. It's not about changing keyboard shortcuts. It implies you can only remap what already exists. It's about giving you infinite canvas to paint on. This isn't unique to Vim. I am just saying having the capability to do so is important.
- calibraxis 14y agoRestarting a program (in various profiles) for tight dev cycles; running unit-tests appropriate to the file I'm currently looking at; using REPLs (Redis, etc); publishing stuff to servers; hacking games which emacs ships with; going through a file and rolling increment certain numbers; and so on.
- lelele 14y ago"Keyboard shortcuts can be changed in lots of editors and OS's." Yes, but you can't change the editing model as easily, e.g. converting a modeless editor in a modal one just by changing a few shortcuts. My take is that there are two camps: people who adapt themselves to the tools they use and people who try to adapt their tools to their ways and their ever-changing view of the world. The former want the tool to help them to get things done, the latter want the tool to help them to get things done their own way. The former look at tools as tools, the latter look at tools as extensions of themselves.