I usually am able to save my vim files but for some reason i am getting E212 can't open file for writing. I am using mac osx. I am confused on how to edit my .vimrc file, and that there are two? one for the system and one for user.
The one you are supposed to edit is either ~/.vimrc (all Vim versions, including 7.4 and up) or ~/.vim/vimrc (only 7.4 and up).
This page give a detail introduction about vi/vim configuration file, you can read it to find what you need.
Related
I recently started using Vi Improved and being a Rainmeter Skin Specialist, when editing my .ini files I can't find a way to add syntax highlight for such files. I searched for a lot of time on stack and git and turned up to nothing. Requesting help at the latest.
TLDR; Need .ini file syntax highlighting for Vim
Vim already has syntax highlighting for *.ini files.
If your Vim is reasonably recent, say 8.0 and up, and you didn't set anything up with regards to Vim (no $HOME\_vimrc, nothing), then your *.ini files should be highlighted without any human intervention at all.
The screenshot below was taken in a test VM with a basic Vim without any setup:
If you have already customised Vim, with a $HOME\_vimrc file and/or with a $HOME\vimfiles directory, then you are in full control, which means that the automatic stuff described above is no longer done for you anymore. And being in full control of Vim pretty much requires that you learn it properly and configure it as you go.
Having EITHER of the following lines in your $HOME\_vimrc or $HOME\vimfiles\vimrc is going to give you automatic syntax highlighting for any recognised filetype:
syntax enable
syntax on
I'm following a tutorial on Uniswap forking (just to learn how this works) and I'm stuck a particular step.
How does one go from:
vim migrations/2_deploy_contracts.js
to
I'm only able to see:
How do I see the folders and directories ?
The user in that particular video is using the NERDTree plugin for Vim. Vim is very powerful and extensible, and it's possible to load a variety of extensions written in Vimscript to customize the interface, add editor features (such as LSP support), or various other functionality.
They're also using a custom colorscheme which is probably based on the Solarized palette. You can also load a custom colorscheme with the :colorscheme ex command.
There is another thing to notice, besides mentioned NerdTree plugin.
I think you are running your command from the wrong place.
vim migrations/2_deploy_contracts.js
This command tries to open the file set by relative path, or creates a new file, if that does not exist. As we see from your screenshots - the file exists in the tutorial, but it does not exist on your machine (the [+] mark after the filename on the second screenshot shows that).
My guess you need to cd to the right directory first (tutorial project root) and then only run your vim command to open the file.
As for your question about seeing the files and directories, you can do it without NerdTree plugin, using built-in netrw. Just type :Ex in vim normal mode.
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. :)
I have recently started using vim and I really like it. I have added a few easy mappings in my vimrc file.
But the problem is I get to use a lot of remote machines a lot of time and I can't copy my vimrc on to them but most of the times I won't have enough permissions to do that.
So, I was wondering if there is any way I can put all my vim mappings in a file and tell vim to run it every time it loads, just like a vimrc?
The action that is "parsing" the .vimrc is called source.
In runtime, you can reapply/reparse your .vimrc by using
:source ~/.vimrc
So if you can somehow copy your .vimrc, even if not in your home, but a folder like /tmp you should be able to source it from there, with
:source /tmp/.vimrc
This question has more details and solutions.
One option would be to specify an alternative .vimrc file while launching the program.
The vim man pages has this to say about specifying a vimrc file:
-u {vimrc}
Use the commands in the file {vimrc} for initializations. All the other initializations are skipped. Use this
to edit a special kind of files. It can also be used to skip all
initializations by giving the name "NONE".
See ":help initialization" within vim for more details.
Note that this option overrides the default vimrc file, so you'll have to specify all of your settings/options in this file.
As was mentioned in another answer, you can place your custom vimrc file anywhere you want (or have access to) and then specify the the -u option with the path to your vimrc file.
You could even combine this method with managing your custom vimrc file in an online version control system (like github) - this way you will be able to wget your file from the web instead of having to manually copy it from machine to machine.
Is there a history of files edited in VIM that persists between
vim sessions, e.g. last 20 opened files.
I tend to edit the same .conf files and I have to navigate to them each time
of course they are spread all over the filesystem.
Actually this behavior IS built in. With default settings you should be able to use the :oldfiles command to view a numbered list of recent files. Then use :e #>4 for example, to edit number 4 in the list. Or :browse oldfiles, according to this answer.
As standard, no, but there's a plugin here that adds this functionality. This one also mentions recent file history on the page, so it may provide an alternative.
As this answer indicates, one may use ctrl-o to jump backward in file history. It will automatically open previously edited files.
You should consider giving ctrlp a chance (if you are not using it now).
It provides the command:
:CtrlPMRUFiles
that let's you select previous opened files. That is besides all the other cool stuff.
I was using the MRU plugin mentioned by #DrAI but once I started using ctrlp I just use that one.
Another popular plugin that provides a mru capability is Unite.
You can use :marks to navigate between recently used files.