Vim colorscheme c++ - syntax-highlighting

How do I get a colorscheme such as this: http://upload.wikimedia.org/wikipedia/commons/5/54/Hello_World_Perl_GTk2.png in gVim?

Well, as gvim and vim share their configuration files you create directory "colors" in ~/.vim and put your_favorite_colorscheme.vim in it.
Then edit your .vimrc file in your home directory with to include this line: colorscheme your_favorite_colorscheme
Here's a nice site to check different themes out:
https://code.google.com/archive/p/vimcolorschemetest/

Related

Shell shortcuts to folders in Windows

I'm learning Vagrant and Virtualbox, Now to add a line to my hosts file in a (windows)
echo "test" >> c:/windows/system32/drivers/etc/hosts
But i'm wondering if i can make a Shortcut to c:/windows/system32/drivers/etc/hosts that i can use in any shell from everywhere.
You might create an environment variable:
[System.Environment]::SetEnvironmentVariable('Youralias','c:/windows/system32/drivers/etc/hosts','Machine)
and then access it using
$env:YourAlias
from PowerShell... If you want to access it from CMD
%Youralias%
should work.
Easier solution using a .bash_profile file
In your home folder (windows) you can make a .bash_profile file and specify aliases.
Go to your home folder
cd ~
make a .bash_profile file and open it in vim or any other editor
touch .bash_profile && vim .bash_profile
add a new alias by adding the following line
alias testfolder="cd /c/testfolder"
save and close your editor.
Explanation someone?
For some reason it only works after i run the following command
source .bash_profile

How do I set up my _vimrc file on Windows?

I want to make some macros to customize some things on gVim, and apparently that's what _vimrc is for. However, I don't have a _vimrc file apparently, so I suppose I must set it up myself. How do I do this, and where exactly should I put it?
You must create that file yourself in your $HOME directory. Don't touch anything that's located in $VIM.

Symlinking gvimrc file?

I wanted to keep all files related to vim in one folder under my $HOME directory, more specifically my gvimrc file. I've moved the original .gvimrc file to $HOME/vim/.gvimrc and created a symlink under my $HOME directory. However, when I run source %, simple functions do not run until I exit and restart the session. For example:
function! EchoSomething()
if &bg == dark
echo "bg is dark"
else
echo "bg is light"
endif
endfunction
This should echo the results on the cmdline, but it show nothing when I source my .gvimrc file.
My preferred alternative to a symlink is to add a source directive to an otherwise empty file at $HOME/.gvimrc
So, if you have another .gvimrc at /path/to/it/, instead of creating a symlink, create an empty file at $HOME/.gvimrc and add the line:
source /path/to/it/.gvimrc
gvimrc (with or without a dot and wherever it is located) is not sourced when you use vim in a terminal.
Since 7.4, CLI Vim and GUI Vim look for the classical $HOME/.vimrc and $HOME/.vim/vimrc and GUI Vim also looks look for the classical $HOME/.gvimrc and $HOME/.vim/gvimrc.
So you can safely drop your symlinks and just rename $HOME/.vim/.gvimrc to $HOME/.vim/gvimrc.

where is ~\.vim folder in mac os? and how to install themes in gvim?

I downloaded color sample pack from http://vim.sourceforge.net/scripts/script.php?script_id=625
it says i should unzip and place it into ~/.vim but where is this folder? I tried unzip it to my usr/share/.vim folder but it is not working, I don't see themes added to gvim Edit>color scheme menu, and i tried "colorscheme sometheme", "color sometheme" in my gvimrc. Both not working for new themes
Isn't the ~/.vim should be the .vim folder in use/share? or I should create a new folder under home?
Note:there is a folder vim73 in my .vim, I guess this doesn't affect anything
thanks for any help!
First of all, open vim, and get help from :help colorscheme
:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
for the file "colors/{name}.vim. The first one that
is found is loaded.
After reading the manual above.
Take the following steps maybe help you:
find runtimepath
:set runtimepath?
It will print out run-time paths:
runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim71,/usr/share/vim/vimfiles/after,~/.vim/after
create directory called colors under one of them if not exist(for example: ~/.vim)
$ ls ~/.vim
ls: cannot access /root/.vim: No such file or directory <== we need create it!!!
$ mkdir -p ~/.vim/colors
copy your color.vim to your colors directory
$ cp /path/to/your/color.vim ~/.vim/colors
restart vim to use new colorscheme
:colorscheme color
(optional) put command above to ~/.vimrc file to make it permanent
In UNIX parlance, ~ represents your home folder which is /Users/<username> in Mac OS X.
You are supposed to put all your custom scripts/colorschemes/whatever in a .vim folder situated in your home folder. In Terminal.app, type each line (without the $) then hit Enter:
$ cd
to be sure you are in your home folder
$ mkdir .vim
here you'll have an error message if ~/.vim already exists; if you don't receive a message it means that the folder is created
$ cd .vim
to move into it
$ open .
to open a Finder window here. At this point you should follow specific indications.

gvim reads _vimrc, vim does not

I'm running vim from an external hard drive, so _vimrc is not in %HOMEPATH% the way it normally is.
_vimrc is inside the vim folder, in addition to the vim73 and vimfiles folders.
_vimrc works when I run gvim, but not when I run vim.
Why?
If you are using MSYS or Cygwin, these programs will cause vim to look for your _vimrc in their own home directories, not the typical Windows home directory.
If this is the case, you can probably fix it by making a link to your _vimrc and placing it in their special home directory.
Seems you are using vim on Windows, if you are using vim binary release with GVIM, it should work without problem, just confirm it by checking your path command "path", and make sure you had installed vim with command line script, it's a option during installation.
If you are using MSYS or Cygwin, just type "type vim" to see which vim binary you are using, and check your home by 'cd ~', it should use the rc file under ~ unless you had some customization with previous binary/shell script.

Resources