Skip to main content
22 events
when toggle format what by license comment
Nov 13, 2015 at 5:08 comment added Arne I like the last one, but for some reasons it doesn't work I get an error expected function name. vimL is too cryptic to me to understand it.
Jul 20, 2015 at 18:35 comment added VanLaser @lcd047 - you care too much then ;)
Jul 20, 2015 at 18:32 comment added lcd047 @VanLaser Because according to the OP my answer wasn't good enough. Regardless of what I thought about it. shrug
Jul 20, 2015 at 18:31 comment added VanLaser I don't see why one would delete a good answer. Variety is good - you may give ideas to ALL the others who later visit the thread and have the same question. And yes, I meant your original critique, and all this thread in general :P
Jul 20, 2015 at 18:28 comment added lcd047 @VanLaser I'm not sure I understand your point. Actually, I'm pretty sure I don't. I deleted my answer simply because the OP has stated that he's happy with the answer he accepted. That's the official recommendation when there are several good answers, and at least one is strictly better than yours, right? The original answer was IMO less than great and I criticised it (I would have done that even if I haven't posted another answer), but I admitted that it's better than mine when the OP said so. Where exactly is the "attack", the "fault", the "competition", and whatever else you saw above?
Jul 20, 2015 at 18:08 comment added VanLaser Then you care about your answer being checked. But one thing is sure, it wasn't the fault of 'garyjohn', so your attack was misplaced. Also: this answer, while originally incomplete, was actually very well thought, because it tried to stay true to the OP intention - something as close as possible to doing an AND between the two autocmds. In any case, this shows the nature of this site: the guy who asks and those who visit the site check and give points, and the more knowledgeable guys compete between themselves, in something that the original OP doesn't care or sometimes even understands.
Jul 20, 2015 at 17:17 comment added lcd047 @VanLaser It's the 'point based system' - Then my method of gaming the system is pretty inefficient, since I actually lost the upvote points by deleting my answer. Not to mention that there are strategies that seem to work better for some people than actually answering questions. :)
Jul 18, 2015 at 20:07 history edited garyjohn CC BY-SA 3.0
added 1018 characters in body
Jul 18, 2015 at 16:54 comment added VanLaser It's the 'point based system' - people giving answers should be encouraged to collaborate between them, not compete. And perfect answers (which are then simply copy-pasted in a vimrc) don't help so much as a short incomplete answer which makes the user sweat a little (which is the real help).
Jul 18, 2015 at 16:42 comment added garyjohn @VanLaser: That's a good idea. I'll try that and post and update. lcd047's answer had a good approach, too. It's a shame he deleted it. I was just trying for an answer that was a simple, direct solution to the original problem. It's expensive to give answers that aren't perfect.
Jul 18, 2015 at 15:04 comment added VanLaser (perhaps using augroup with an initial autocmd! would solve all problems)
Jul 17, 2015 at 18:37 comment added flashburn @lcd047 I don't work with very large files, so this works for me.
Jul 17, 2015 at 17:34 comment added lcd047 Performance is not a problem. Running the function stripTrailingWhiteSpaces() several times against the same file might have unintended consequences though. Also, the more autocmds you have for the same event for the same file, the more likely you are to run into some really race conditions. Try searching vim_dev archives to get an idea. Then again, what do I know, it might just work for you, right?
Jul 17, 2015 at 17:21 comment added garyjohn @lcd047: Really? If you do all that and notice a performance degradation, let me know.
Jul 17, 2015 at 16:59 comment added lcd047 So if you open 5 Python files you'll have 5 autocmds instead of a single one, all on write. Then if, say, 3 of these files get hidden, then get shown again, FileType gets re-triggered so you get 3 more autocmds, also on write. This is brilliant, I wonder why I didn't come up with this solution. :)
Jul 17, 2015 at 15:58 comment added VanLaser (... and if you run :w, the event will run only for the current buffer)
Jul 17, 2015 at 15:57 vote accept flashburn
Jul 17, 2015 at 15:48 comment added VanLaser The FileType autocmd above will fire for every file you open with the correct filetype, and will setup a buffer-local event for each of those files. So if you run :wa, vim will run registered events for each buffer, before saving to file.
Jul 17, 2015 at 15:46 comment added flashburn I need some clarification. Let's say I have multiple open unsaved buffers, buf1, buf2 and buf3. All of them have trailing spaces. I'm currently working on buf3. If I save buf3 the autocmd will be executed in buf3. Here is my question: Will it be executed on buf1 and on buf2? Based on the documentation from autocmd-buflocal it seems like that it won't
Jul 17, 2015 at 15:41 comment added VanLaser If the files were opened with the correct filetype, the FileType autocmd in the answer would have already set up the second autocmd (BufWritePre) to fire when you save them.
Jul 17, 2015 at 15:30 comment added flashburn What if I want to run this on all the files that are currently open, i.e. I execute :wa?
Jul 17, 2015 at 15:20 history answered garyjohn CC BY-SA 3.0