Editing _vimrc in Windows - vim

I am having some trouble with VIM on windows, and I was wondering if anyone could be of assistance. As of right now, I am trying to make it so that when VIM starts, it changes it's working directory to one besides the default (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Vim 7.3). The way I am going about this is adding in cd $HOME\Desktop\VimFiles, where $HOME is C:\Users\Alphabet (Alphabet is the name of my account).
The issue I am running into right now is that after opening up _vimrc and adding in the line stated above, I cannot save the file, even when forcing it (with w!). I was wondering why this is and how I can go about fixing this. As an added note, I am running this in GVIM.
Note: I have attempted to do the same thing in VIM, and am able to edit the _vimrc file fine, but when I go to it's location and open it with GVIM or Notepad++, the "cd" line doesn't show up. Is there a reason for this?
Any help is appreciated. Thank you!

It looks like you are trying to write a file in a protected directory without the proper privileges.
In Vim, :echo $HOME tells you where you are supposed to put your _vimrc. In your case, your _vimrc should be C:\Users\Alphabet\_vimrc and you should put your plugins and whatnot in C:\Users\Alphabet\vimfile\.
Never touch system files!

Related

Editing .vimrc file to make 'set ft=python' a default setting and something more

I am a new comer to the vim world, and I have just installed spf13-vim for a quick start. Apart from that I have not touched my .vimrc file.
I mainly use vim to write some python scripts on a remote server, so I have to type 'set ft=python' each time I open a file using vim. I am wondering if it's possible to edit my .vimrc file to make python a default choice of vim.
Another confusing thing is that each time I type a blank in vim, it shows a inverted question mark on my vim screen. I think it's because of some mismatch in file encoding, but I have no more idea about it.
I know it's a stupid question, but right now I can't solve it myself. Any help is appreciated.
Edit:
I have solved the problem of setting python default by write 'set ft=python' to my .vimrc file. (I didn't know contents in .vimrc are commands in vim) But I still don't know how to eliminate the inverted question mark when I typed a blank char, even after I do some search.
Name the buffer you're editing from the start, don't forget the :filetype plugin in your .vimrc and then things will work correctly.
In any way having :set ft=whatever in your .vimrc is twice wrong. First it'll apply to all new sessions opened without a file. Moreover it'll only apply to the first buffer. I.e. it won't work with :new.

How to make vim point to a syntax file located at a custom path

I'm trying to add a custom syntax highlighting file mysyn.vim in the syntax library of vim. Unfortunately, as I'm not the administrator I don't have access to usr/share/vim/vim72/syntax space. Hence, I was wondering if there is a way I can place the syntax file in my local area /home/doug/mysyn.vim and make vim look at this file by editing the .vimrc (.vimrc file is in my local space as well).
To get over this problem, I also considered copying my entire vim directory from usr/share/vim to /home/doug/myvim/ and change the default runtime path of vim. I tried doing this by adding the line let $VIMRUNTIME=\home\doug\myvimfiles\ to the .vimrc file. However, I get an error saying VIMRUNTIME : Undefined variable
So, are there any suggestions of how I could do this?
Thanks
With a decently recent version of Vim you can just create a directory ~/.vim/syntax and put syntax files there. You seem to be running Vim 7.2 though, which is some 8 years old. Getting your sysadmin sacked might be the better choice. :)

Change vim colorscheme on school's server

I have created my own colorscheme, and would like to set it as my default in my ~/.vimrc file.
My problem being, (as I understand it), I am on my school's linux server (Ubuntu 14.04), where many hundreds of students have accounts.
I have read into this, and as I see it, I cannot change the colorscheme because the directory that vim is searching through is /usr/share/vim/vim74/colors/, which I do not have access to.
How might I go about adding my colorscheme as default for my acount?
Perhaps editing the ~/.vimrc file to search for a file within my home directory (~/.vim/colors/scheme.vim)? I have tried that, but could not make any progress.
Am I out of luck on this?
Thanks
The standard location is:
~/.vim/colors/colorschemename.vim
and you call it in your ~/.vimrc like this:
colorscheme colorschemename
NEVER do anything in /usr/share/vim/ unless you are the administrator of a multi-user system and know what you are doing.
I think if you have enough space, you can copy whole /usr/share/vim/vim74 to your local directory and then set $VIMRUNTIME environment variable to this local directory.
Other way is to put source $HOME/.vim/colors/scheme.vim in your .vimrc .

iTerm don't save 'set' parameters to use vim

I'm using iTerm2 with vim to work with python files. When I create or start editing a file using 'vi', I always have to introduce all the configuration values like ':set number', ':syntax on', etc. I have edited '.vimrc' from MacVim to save this parameters, but when I restart iTerm I have to put the values again, the configuration didn't save this 'set' values.
This is an example how i start the program: 'vi file.py'. It opens vim but without the 'set' values I have previously introduced.
It would be nice if someone could help me. Thank you.
First rule: NEVER DO ANYTHING IN VIM'S RUNTIME FILES.
In Vim, do :echo $VIM. That directory, /Applications/MacVim.app/Contents/Resources/vim, in your case, is off limits. You are not supposed to change/add/remove anything, there. There's no good reason to even look at it!
Second rule: ALWAYS DO CUSTOMIZATION IN YOUR HOME DIRECTORY.
Your customization belongs to your home directory.
Your vimrc is here:
~/.vimrc ~/ being a shortcut for /Users/username/
Your vim/ is here:
~/.vim/ ~/ being a shortcut for /Users/username/
You must create those files and directories if they don't already exist.
Note: MacVim is a GUI app that won't work in your terminal unless you did some (simple) specific things. Did you do anything toward that goal? It looks like you are just using the default Vim that will obviously not source MacVim's runtime files.

VIM: Overwriting system vimrc

I work on multiple MAC OS X systems, which do not save changes after log out. As you know VIM is on every new mac, just type in vim in the terminal. I always bring my vimrc file with me, and the problem is that every single time I start vim i have to load it with :so command.
I want to use the fact that vim is available on every unix, but I also want to take advantage of the nifty integration with the terminal for doing quick tests, I just switch back to the terminal, but for that I need to close vim. When I reopen it, I again have to load the vimrc. And I am a newb, I don't even have plugins yet...
I want to keep the integration with the terminal and only develop a super quick way of introducing my changes to vim. Think of the conditions as if though you are sitting on newly installed operating system.
Thanks !
Not directly to your question, but you can always invoke vim with -u, which will let you specify your vimrc file instead of launching vim and then running :so.
The default location for your .vimrc file is ~/.vimrc (on the mac, ~ is /Users/_you_, eg /Users/matt). If you can write your file there, it will be loaded when vim starts up every time.
The system vimrc file on the mac is at /usr/share/vim/vimrc, but it sounds like these systems are not under your control, so you won't be able to write that file. Have a look at: How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?, which uses the -u option to change the path vim looks for plugins under. But, in all cases, you must either be able to write your .vimrc into your home directory (which it sounds like your system does not permit) or specify the path to it at runtime (as with the command-line option I mention above, or with the normal command :so which you're currently using).
Depending on the kind of testing you need to do, you can always run shell commands within vim, by using the ! in normal mode. For instance, I frequently make changes to a python file in a buffer, and then (in normal mode) run !nosetests within vim—that writes terminal output into a temporary buffer at the bottom, and doesn't require me to leave or suspend vim. I can review the output, and any key-press takes me back to my buffer.
I don't have any experience with Mac-Os terminal. However I think if you could cp your .vimrc file to your home directory. everytime you start vim, vim will load the .vimrc file from your home directory.
If you want to swtich back to terminal from vim to do some testing/execute some commands and back to vim. you could consider to:
open multiple terminal windows
try something like screen or tmux. personaly I am using tmux, and it's very nice.
try Conque Shell plugin: http://www.vim.org/scripts/script.php?script_id=2771 I have this plugin installed too.
type Ctrl-z in vim to back to terminal
If you want to sync your .vimrc on different machines, you could put your .vimrc file in
a scm repository like gitHub, bitbucket... (I perfer this option, since you could have different branches for different settings)
dropbox
I hope this helps.
How is it possible that your changes are not saved after you log out? What would be the point of such a machine? An internet kiosk in an airport? Do you log as a user without a "home" directory?
If you have a "home" directory, just create a blank ~/.vimrc and put your settings there.
If you don't have a "home" directory but you are able to write somewhere else, create a blank vimrc file where you can, write your settings there and learn this command by heart:
$ vim -u /path/to/your/vimrc
If you don't have a "home" directory and you are really sure that you can't save anything on these machines, put your settings in a file somewhere online, preferably a place under your control, and learn this command by heart:
$ vim -u http://domain.name/yourvimrc
If you are lucky, the command you use will be remembered by your shell for you and it will be easy to issue it again without much typing.
For running your tests, you can either:
Hit <C-z> to suspend Vim. You are back at the prompt from where you started Vim and you can do your thing. Type $ fg to go back to Vim.
Type :sh to launch a new shell from the current directory. To go back to Vim, type $ exit.

Resources