I have mismatched plugin files floating around ~/.vim; I am experiencing a corrupted behavior within vim itself, and both my .vimrc and .gvimrc are filled with things I don't understand.
Examples: NERDTree plugin displays two identical file drawers on start, settings in .vimrc and .gvimrc aren't manifesting themselves.
Is there any way that I can completely "re-install" vim? Or, is there a way that I can get a new .vim folder, and start over form scratch? I want to learn vim, but it's hard with all these plugins installed. I just want to start with a plain vanilla installation.
Thanks for any help in advance.
cd
mv .vimrc .vimrc-old
mv .vim .vim-old
touch .vimrc
mkdir .vim
To remove everything from your vim configuration remove the entire .vim folder as well as everything from your .vimrc file. Keep the empty file in place though because without it vim will start in compatible mode by default and you almost certainly don't want that.
Note that there are system-wide files that are not stored in your home directory but if you haven't tweaked any of those then the above steps are all you need to do.
I know this is a bit old question but there is another useful command you can use mv ~/.viminfo ~/.oldviminfo
As mentioned in this answer, I moved .vim and .vimrc. which resulted in the error below
bash: /usr/bin/vim: No such file or directory
I'm not sure why I was facing the error above. When I moved only the .vimrc to .vimrc-bkp and created a new empty .vimrc, vim started working like a fresh install.
Related
Even though I I added "set noundofile" in the "_vimrc" file in the installation directory of Vim it still creates undo files.
You have no business editing anything in Vim's installation directory. Whatever you do to configure Vim must happen in your own runtime directory, located in your own "home directory", and nowhere else:
%USERPROFILE%\vimfiles
If it doesn't already exist, create it yourself.
Disabling undo files is indeed done with set noundofile, that you are supposed to put in your own vimrc, under the directory mentioned above:
%USERPROFILE%\vimfiles\vimrc
That file is sourced after any system-level vimrc so whatever you put in that file will take precedence. It is your vimrc.
I want vim to save folded code after I've closed the file. I've added the following code to both /etc/vimrc and ~/.vimrc:
au BufWinLeave ?* mkview
au BufWinEnter ?* silent loadview
When I open a file as a regular user (vim file) it works as expected. If I instead open with sudo vim file it doesn't save folded code.
I know /etc/vimrc is being read. My theme is set at the bottom of that file and is working fine. I ran into a similar problem last week installing the vim surround plugin. When that was installed in ~/.vim it only applied to vim file. To get it working with sudo I had to install it separately in /usr/share/vim/current. What could be causing this?
Prolog
In fact you answered your question, so this is indeed the same issue you had before. It is caused by the algorithm Vim uses to find its configuration (see :help initialization). But I wouldn't call your solution a correct one. See :help $VIM for information how you can use your configuration in sudo environment (e.g. being root).
As for your current issue.
See the following quotes from the documentation. :help :mkview:
:mkvie[w][!] [file] ...
When [file] is omitted or is a number from 1 to 9, a
name is generated and 'viewdir' prepended.
...
And :help 'viewdir':
'viewdir' 'vdir' string (default for ... for Unix: "~/.vim/view", ...
So after doing sudo all views are stored by Vim at /root/.vim.
Solution
Make viewdir point to your ~/.vim/view directory, with something like the following in /root/.vimrc:
:set viewdir=/home/user/.vim/view
Though, this approach has some issues itself:
Updating views saved by root will cause permission errors.
You wont be able to pass stored views for files under /root or /home/user, because Vim generates file names with tilde instead of full paths.
The first issue can be solved by running chown or chmod on new view file right after executing :mkview command. It should be something like:
execute '!chown user:group' eval('&viewdir').'/'.substitute(expand('%:p:~'), '/', '+=', 'g').'='
But I don't know good solution for the second issue, can only suggest writing a script to convert file names to full paths.
I'm having difficulty getting MacVim (7.3-64) to recognize my .vimrc and .gvimrc files since upgrading to OS X 10.7.3. Previous, I've simply symlinked my .vimrc and .gvimrc using these commmands:
$ ln -s ~/.vim/vimrc /usr/local/Cellar/macvim/7.3-57/MacVim.app/Contents/Resources/vim/.vimrc
$ ln -s ~/.vim/gvimrc /usr/local/Cellar/macvim/7.3-57/MacVim.app/Contents/Resources/vim/.gvimrc
However, when I currently symlink my rc files, I can not get MacVim to recognize them. I've installed MacVim via Homebrew. Does anyone have any suggests as to what the problem could be?
The ~/.vim/ folder (for colorschemes and scripts) and the ~/.vimrc file (for custom settings and mappings) are guaranteed to work on every UNIX-like systems but neither of these are required for Vim (and MacVim) to work properly.
Start without symlinks or whatever : no .vim folder and no .vimrc or .gvimrc in your home folder. Does MacVim work? You are supposed to see a window with some introductory text, do you see that?
Quit MacVim and turn to the original .(g)vimrc files you want to use: where are they located? Where did you get them from? What is their content? Do you actually, really need them? Do their names actually start with a dot (do you see them or not in the Finder)? What is their encoding (in vim, :set fileencoding? and in the terminal, $ file /path/to/original/.vimrc)? Please, paste the content of the .vimrc file you want to use in your question.
If you are absolutely certain you need these files to work efficiently in Vim and assuming you actually have a custom .vimrc somewhere on your Mac, open Terminal.app and type this command (without the $):
$ cp /path/to/original/.vimrc ~/.vimrc
to copy your .vimrc to the canonical location.
Now launch MacVim. What do you see? You are supposed to see a window with some introductory text, is that what you see?
If MacVim doesn't work correctly with your ~/.vimrc you might want to comment its content, relaunch MacVim, uncomment a few lines and so on until you eventually find a bad setting.
Just put your .vimrc and .gvimrc into your home directory, i.e. ~/ It's picked up there allright.
BTW, you don't need to link to the homebrew dir. Those rc files are default files which you can override with your local user files.
I have mismatched plugin files floating around ~/.vim; I am experiencing a corrupted behavior within vim itself, and both my .vimrc and .gvimrc are filled with things I don't understand.
Examples: NERDTree plugin displays two identical file drawers on start, settings in .vimrc and .gvimrc aren't manifesting themselves.
Is there any way that I can completely "re-install" vim? Or, is there a way that I can get a new .vim folder, and start over form scratch? I want to learn vim, but it's hard with all these plugins installed. I just want to start with a plain vanilla installation.
Thanks for any help in advance.
cd
mv .vimrc .vimrc-old
mv .vim .vim-old
touch .vimrc
mkdir .vim
To remove everything from your vim configuration remove the entire .vim folder as well as everything from your .vimrc file. Keep the empty file in place though because without it vim will start in compatible mode by default and you almost certainly don't want that.
Note that there are system-wide files that are not stored in your home directory but if you haven't tweaked any of those then the above steps are all you need to do.
I know this is a bit old question but there is another useful command you can use mv ~/.viminfo ~/.oldviminfo
As mentioned in this answer, I moved .vim and .vimrc. which resulted in the error below
bash: /usr/bin/vim: No such file or directory
I'm not sure why I was facing the error above. When I moved only the .vimrc to .vimrc-bkp and created a new empty .vimrc, vim started working like a fresh install.
I share an user with other people.
Everyone has created a directory into home directory and everyone is working in his "own" directory.
I want to use my own setting when I use vim and I don't want to bother others with my preferences.
I created my .vimrc file into $HOME/my_directory
I've defined an alias my_vim="vim -u /full_path_to_home/my_directory/.vimrc"
When I edit a file with my_vim, I don't have the right colors.
I have the same problem when I use the command
:source /full_path_to_home/my_directory/.vimrc
If I copy my .vimrc file into $HOME directory, everything is fine.
Where is the problem ?
From :help vimrc
If Vim was started with "-u filename",
the file "filename" is used.
All following initializations until 4.
are skipped.
So by specifying a vimrc file, its ignoring the system-wide vimrc (/erc/vimrc/) where syntax highlighting and other things are configured. You can work around this problem by adding the following code to the top of your vimrc:
if filereadable("/etc/vimrc")
source /etc/vimrc
endif
If this sort of thing comes up a lot, I would recommend changing your $HOME to point to the current $HOME/my_directory whenever you log in.