Vim Tips Wiki

New tips March 2009

This page is an archive listing tips created in March 2009. Please do not edit this page because discussion has finished. If you have any comments, edit the appropriate tip page.

Alternatively, comments can be posted on the mailing list.

Proposed new tip Link Current consensus
Auto indent on finishing a code block discuss Merged to VimTip597
Change cursor shape in different modes discuss Keep
Editing crontab discuss Keep
Creating a screenshot discuss Merged to Vim Tips Wiki:Community Portal
Determining indent settings (shiftwidth etc.) for python files discuss Merged to VimTip1231
Indent C blocks where braces are opened and closed on a single line discuss Keep
Make-compile current buffer discuss Merged to VimTip210
Using GUI color settings in a terminal discuss Keep

Titles of merged tips[]

As a general policy, I favour deleting the titles of proposed new tips that have been merged elsewhere (while keeping those titles which happen to be useful as redirects). In this case, however, I intend keeping three of the titles of the four merged tips. I do not see why we should keep the title "Determining indent settings (shiftwidth etc.) for python files" although we might want to make simpler redirects that point to Set indent parameters for Python files (tip 1231), for example "Determining indent settings". Any opinions? JohnBeckett 11:40, 25 July 2009 (UTC)

I am now OK with the delete, mainly because I don't like the title. At first, I figured the current title contains several search terms I would potentially use, and should therefore show up in searches, so why bother creating new titles? But I did a little experiment.

Were I to search for this information, my first few choices for search terms would be:

While Set indent parameters for Python files shows up in the first two searches, none of these searches contain the new title, and I think we would be hard pressed to find a non-contrived search term that contains the new but not the old. I think we should create a redirect "determine indent settings" and/or "determine python indent" and delete the current proposed title.

--Fritzophrenic 13:58, 26 July 2009 (UTC)

Auto indent on finishing a code block[]

Merged to VimTip597 (and just for the interest, I did another history merge). I will keep the new title as a redirect, although I do not intend doing that for other merged/moved/deleted new tips, except where advised. JohnBeckett 04:23, 15 July 2009 (UTC)

Change cursor shape in different modes[]

Keep I haven't got a clue whether the tip works, or how badly broken it is (see the comments). Also, the tip has a link to 746 Change cursor color in different modes which could be used as a merge target. However, my current inclination is to keep the tip because even if it does not work, I imagine there are plenty of people who would want the feature, and who would appreciate finding advice, even if that advice was covered in a "doesn't work well" warning. In the future, information on other systems might be added. JohnBeckett 04:23, 15 July 2009 (UTC)

Agreed. It looks to me like the comments say "breaks in these specific circumstances..." rather than "doesn't work". Future readers can use the tip as-is if they don't have those specific use-cases, or know what to fix if it doesn't work for them. --Fritzophrenic 14:26, 23 July 2009 (UTC)

Editing crontab[]

Keep I renamed to simplify title and remove typo. Old title was: Configuring vim so it can be callled from "crontab -e" JohnBeckett 09:35, 4 July 2009 (UTC)

Creating a screenshot[]

Merged to Vim Tips Wiki:Community Portal. JohnBeckett 11:48, 24 July 2009 (UTC)

Delete. This is trivial information that is probably already in the repertoire of most people that use Vim. For those few that don't know about it, why on earth would they search on the Vim Tips Wiki for that information? Furthermore, this tip consists of nothing but a collection of external links, and I think I've made my stance on such tips clear in the past. --Fritzophrenic 16:59, 7 July 2009 (UTC)
In general, I would agree. However, George Reilly is the author (George is a vital contributor to the Windows-specific stuff in Vim) so I am inclined to sacrifice my principles. Is there any chance we could (eventually) make a "how to ask an intelligible question" tip out of this? The whole exercise is of course pointless because the clueless would never look here, but I suppose George felt it might be useful to have a place to point them for next time. JohnBeckett 03:47, 8 July 2009 (UTC)
Perhaps, then, we should encourage George to move this content to a user-subpage, until such a time that we are ready to make it into a "how to ask a good question" tip? George, any input? --Fritzophrenic 04:00, 18 July 2009 (UTC)
How would you feel if the material was moved to a brief new section at the end of Community Portal? It could be argued that it goes with "Asking questions". JohnBeckett 11:47, 23 July 2009 (UTC)
I think that's a great idea! Let's do that. --Fritzophrenic 14:26, 23 July 2009 (UTC)

Determining indent settings (shiftwidth etc.) for python files[]

Merged to VimTip1231. I simplified 1231 and the new tip and I think they belong together and work ok in one tip. JohnBeckett 11:40, 25 July 2009 (UTC)

Will think some more: Merge to Set indent parameters for Python files, or keep as "Detecting indent settings"? JohnBeckett 11:48, 24 July 2009 (UTC)

Sorry, yes I recommend keeping this, and I saw your comments on the page itself and thought you wanted to as well, so I just put it in the summary table rather than spending time to comment.

I think it would be nice to show a vimscript-only implementation, but it seems that the content of VimTip1231 only detects tabs vs. spaces and sets the shiftwidth, etc. to a constant value. Maybe this is good enough; we could present the vimscript content first, mention that it's an incomplete solution, then show the two plugins detailed in this new tip as a more complete solution. I'd probably keep the new title as well as the old if we do merge, because I would probably search for "determine python shiftwidth" or something similar were I to look for this information. Maybe sometime someone will improve the detection script to also detect shiftwidth.

I guess that I tentatively support a merge, but I have no strong feelings either way between merging and keeping as-is.

--Fritzophrenic 13:49, 24 July 2009 (UTC)

There is a vimscript-only implementation of indent detection, IndentConsistencyCop. I've added an entry under the Other Solutions heading. -- Inkarkat 15:07, 24 July 2009 (UTC)
Thanks! I think the other plugin mentioned in this section is also vimscript only, but it's good to know all the options. What I meant, however, is a vimscript-only implementation that we could use as an example of how such a thing might be done, were you to do it by hand. Not as the final solution (a user should probably use one of the three plugins) but as a learning opportunity. --Fritzophrenic 16:38, 24 July 2009 (UTC)

Indent C blocks where braces are opened and closed on a single line[]

Keep Little short and unnecessarily vague, but good. JohnBeckett 11:44, 12 July 2009 (UTC)

Kind of neat, and provides a very simple and immediately useful demonstration of overriding the default filetype indent rules. Keep, unless we have another filetype indent tip you'd like to merge it to. I think it is fine on its own. --Fritzophrenic 16:59, 7 July 2009 (UTC)

Make-compile current buffer[]

Merged to VimTip210 (while keeping the new title; 210 has been renamed). I tried some funky stuff and have combined the edit histories of the old and new tips. Amazing. JohnBeckett 04:54, 14 July 2009 (UTC)

This is an interesting and potentially useful but very trivial function/mapping. Do we have somewhere to merge it? I'd like to keep the info but am not sure whether there is enough content to make a full tip out of, though it is too much for Short mappings for common tasks IMO. --Fritzophrenic 16:59, 7 July 2009 (UTC)

We have these (345 has some relevant info including an F7 map):

Perhaps rename 210 to something more generic and merge this tip to 210? Maybe keep this tip's title as the new name for 210? JohnBeckett 11:44, 12 July 2009 (UTC)

I agree with a merge to 210 and rename. Maybe it would actually be better to merge 210 into this one instead (and redirect 210) to avoid page title confusion? --Fritzophrenic 02:34, 13 July 2009 (UTC)

Using GUI color settings in a terminal[]

Keep JohnBeckett 09:35, 4 July 2009 (UTC)

Well, it's definitely a useful tip. I think it's much better to recommend CSApprox over GuiColorScheme, but I might be biased since I'm the author. Here are a few reasons:

  • Doesn't work by reading and parsing the colorscheme. GuiColorScheme gets confused by things as simple as leading spaces on :highlight lines, let alone conditionals, or a colorscheme that sources another then makes some small tweaks
  • Works transparently, doesn't require a separate command to set the scheme, or a hack to load the plugin before plugins are normally loaded, and doesn't make any changes if the scheme is already high color or if the terminal doesn't support enough colors (though it warns loudly in that case).
  • Handles 3 different 256-color palettes. It can handle choosing the correct colors even given the subtle differences between konsole, xterm, and Eterm's color palettes, as long as it knows what the terminal is (either because $TERM is set properly or a global variable is set saying "I'm a (konsole|eterm)".
  • 90% as many downloads on as GuiColorScheme, and with a higher rating, despite being available for 1/4 the time.

The only disadvantage is that making it work in a vim without +gui requires running gvim and using :CSApproxSnapshot to dump out a version of the scheme that supports 88-/256-color terminals. CSApprox.vim works by querying the current gvim colors, and unfortunately this isn't possible where vim is -gui (yet, hopefully I can convince Bram to change that when I give him a patch). godlygeek 11:11, 15 March 2009 (UTC)

In response to your comment, latest version of guicolorscheme does handle properly indentation before :highlight command. I know since I stumbled upon precisely that issue too and I submitted a patch to fix it among minor other things. The author updated the script accordingly. I have not tried CSApprox yet, so I won't compare with it but from your description, CSApprox seems interesting too. dominiko Mar 15 16:08:28 UTC 2009.
I have added info in this tip about CSApprox plugin. dominiko Mar 17 21:19:11 UTC 2009

Now that this discussion has started, I'll add my voice in the Keep section, especially since both plugins are now mentioned in the tip. However, I'll also watch this page, and remind other commentators that they should do so too, because, as mentioned here at top, until March 31 a bot might remove all our comments. — Tonymec 08:43, 18 March 2009 (UTC)