On 2012-01-11, flebber wrote:
> When working with vim especially on windows creating a new file can be
> a bit of a pain as I have to navigate the directory structure to do
> this.
> 
> I found this 
> http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
> which is good if there is already a file open I guess.
> 
> But I was wondering if I could set the default opening directory by OS
> instead.
> 
> On linux its sweet ~/Programs really aint that much to type.
> 
> On windows XP its sweet as well c:/MyPrograms
> 
> But windows 7 is where i am getting annoyed, you can't write directly
> to c:\ so the directories I have to navigate to create open or close
> files are
> C:\Users\renshaw family\Documents\Programs
> which is really starting to grind my goat, fine for me bad for the
> goat.
> 
> Anyhow is there any easy way to acheive this?

One way to do that is to edit the icon/shortcut that you use to
start vim.

On Windows XP, right-click the shortcut, select Properties, select
the Shortcut tab, and enter the desired directory in the "Start in:"
box.

Using KDE on Fedora 11, right-click the icon, select Icon Settings,
select the Application tab, and enter the desired directory in the
"Work path:".

Windows 7 and GNOME presumably have something similar.

Alternatively, you could put something like this in your .vimrc
(untested):

    if has("unix")
        cd ~/Programs
    elseif has("win32")
        if exists("$OS") && ($OS == "Windows_NT")
            cd C:/MyPrograms
        else
            cd "C:/Users/renshaw family/Documents/Programs"
        endif
    endif

I am assuming that Windows 7 sets $OS to something other than
"Window_NT".  I just opened gvim on Windows XP, executed ":r !set"
and looked for a likely environment variable.  Now that you get the
idea, you might be able to find a better variable to test.

HTH,
Gary

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to