Hello All, I've found two tasks that are done in vim scripts routinely and it would be nice to streamline them:
Here's the first one: "If some variable isn't set yet, then set it to a default value". The code always looks something like this: if !exists("g:MyScriptSetting") let g:MyScriptSetting = "default_value" endif To make this easier, I would love to see is the vim 7.0 "get()" function expanded to handle regular variables. The get() function is currently defined this way: get({list}, {idx} [, {default}]) Get item {idx} from List {list}. When this item is not available return {default}. Return zero when {default} is omitted. get({dict}, {key} [, {default}]) Get item with key {key} from Dictionary {dict}. When this item is not available return {default}. Return zero when {default} is omitted. How about adding this: get({string} [, {default}]) Get value from variable {string}. When this variable does not exist, return {default}. Return zero when {default} is omitted. The second one is: "Make these vim settings during this function call only, so save the current values first, set them to what I want, then restore them before leaving". There is an item on the TODO list to make this easier: ":with option=value | command": temporarily set an option value and restore it after the command has executed. The problem is that this could get ugly if many options need to be changed, and those settings have to be made *every time* the routine is called. Typically, the function only works correctly when those settings are set. It would be nice to see something like the current setlocal command instead: :sett[emp] ... Like ":set" but set only the value local to the current function. The value is restored to the value set before the current function was called when the function ends. Not valid outside of a function. What do you think? David