I have installed cygwin and cscope on my windows 7 machine. I created a .vimrc file in $HOME directory with the following settings:
syntax on
set hlsearch
set ic
When i ran cscope, selected a file and tried to find some text, it is not highlighting(it get highlighted when using vim/vi on individual file).
I added "alias vi=vim" too in my $HOME/.bashrc file.
Please help me resolving this and understanding why it is happening, as i think cscope should open files using vi/vim.
You can check with the :scriptnames command which ~/.vimrc configuration and plugin files are loaded.
I doubt that csope is going to use your alias. It's probably using the EDITOR or VISUAL environment variables. Make sure those are set to /usr/bin/vim and not /usr/bin/vi. On Cygwin, vi and vim are two different executables. vi is configured to be mostly vi-compatible, while vim has most of the vim features turned on.
Related
Here is my .vimrc
1 syntax on
2 set ts=4
3 set number
4 set smartindent
5 set shiftwidth=4
However, I tried to edit HelloWorld.java and HelloWorld.c. Both have pure regular black font. No any highlighting!
I also tried :syntax on after the vim is open, but no luck.
\>vim -version
VIM - Vi IMproved 7.3 (2010 Aug 15)
\>cat /etc/*-release
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
When you edit the file, are you using
vim filename
This can matter. In some server configurations, if you do vi filename you get vim, but it's a very stripped down version of vim that is very much like the original vi (which does not, among other things, do syntax coloring). On a system configured in this way, if you instead type vim filename, you get the full featured vim.
I just worked through this with a person who was on a server that had the vim-minimal package installed as well as another vim package. I suspect (but did not verify that) the vim-minimal package installed its executable as /bin/vi.
The difference was very clear when you looked at the actual files (i.e. ls -l /bin/vi vs ls -l /usr/bin/vim)--one was about ten times the size. Both of them were actually vim, same version number and everything, but the /bin/vi one was compiled with very few features enabled.
To make it even more confusing:
vi existing.pl
opened the .pl file, gave no syntax coloring
vi [enter]
gave the vim splash screen, and from there
:e existing.pl
opened the file with syntax coloring on.
A comment from Jan Wilamowski suggests checking by doing:
vi --version
If that shows that the syntax feature was not compiled in, try
vim --version
and see if it is compiled in there.
You'll need to install the vim-data package on openSUSE for vim syntax colouring to work.
Sounds strange, I know that this is not pulled in by default with the vim package but AFAIK it's for people who want to create tiny base installs.
Package vim-data contains the runtime files.
Also make sure your remote environment has an appropriate TERM variable set TERM=screen-256color, TERM=xterm, TERM=xterm-256color should all work just fine with ssh and ssh with screen/tmux.
If all above have been done and you see some underlines and bold instead of actual colors... this might work for you:
export TERM=xterm-color
in your .vimrc, I don't see filetype setting. you could try to add:
filetype plugin indent on
to your vimrc.
if you don't have set nocp, add this line too.
if you read :h filetype
:filetype on
Each time a new or existing file is edited, Vim will try to recognize the type
of the file and set the 'filetype' option. This will trigger the FileType
event, which can be used to set the syntax highlighting, set options, etc.
For some strange reason on MacOS, 'syntax on' must be the first line in your .vimrc file. The line appears to be ignored if placed elsewhere in the file.
One item not mentioned is :set syntax=<type>, e.g. :set syntax=markdown.
This has been successful in instances where other techniques above were not.
I know how to turn syntax highlighting on and off in vim by running this in the editor:
:syntax on/off
But I want syntax highlighting to be enabled by default, so I don't have to turn it on every time I run vim.
How do I do this?
Edit your $HOME/.vimrc (Unix/Linux/OSX) or $HOME/_vimrc (Windows) to include the following line:
syntax on
EDIT
If your syntax highlighting doesn't work when you start Vim, you probably don't have a
$HOME/.vimrc or $HOME/_vimrc (known collectively as vimrc from now on). In that case, you have two options:
Create an empty vimrc.
Copy vimrc_example.vim as your vimrc (recommended, thanks #oyenamit). You can find vimrc_example.vim in the runtime directory.
The location of the runtime directory varies between operating systems:
On my system (Arch Linux, and Mac, thanks #totophe), it's in /usr/share/vim/vim73.
On Windows, it's in \Program Files\Vim\vim73.
Also, to highlight the syntax of a Specific File TYPE (or programming language extension), you can use following commands, while file is already opened in Vim and you want to try syntax highlighting on the fly:
:set filetype=php
OR shortcut:
:se ft=php
Above commands will change the syntax-highlighting for currently opened file as it should be for PHP code.
Uncommenting the "syntax on" in vimrc file.
Move to the directory,
cd /etc/vim/
vim vimrc
now search "syntax" and uncomment it. Save it and reopen the file in vim.
For anyone that gets here because of TurnKeyLinux using vim-tiny which doesn't have the syntax module enabled try this article to install full vim
http://www.turnkeylinux.org/forum/support/20140108/solved-bash-command-not-found-after-replacing-package
tl;dr
# apt-get remove vim-tiny
# apt-get install vim
# hash vim
# vim
I also found that this is one of the lessons in vimtutor.
To find it, you can type command vimtutor in your Terminal (I used on Mac), and scroll down to see if there is a lesson called CREATE A STARTUP SCRIPT (for me it was Lesson 7.2), where it describes how to set up an initial vimrc file.
In my $HOME/.vimrc I load a color scheme (solarized) and found that I need to place syntax on after I load the plugin. If it's before loading the plugin it doesn't work.
" this turns syntax highlighting on by default
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'lifepillar/vim-solarized8'
syntax on
" this does not turn syntax highlighting on by default
syntax on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'lifepillar/vim-solarized8'
To Find the vimrc_example.vim as suggested in answers above
Command : sudo find /usr -iname "vimrc_example.vim"
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.
3.3 in cywing 2.721, the installation was made using cywing, every thing works but when I try to use the following command.
:Explore
vim said E492: Not an editor command
also neither :Sexplore or :Hexplore works.
is there any way to activate this functionality?
This is in machine with windows xp.
Well I solved reading the
:help usr_01.txt
It said that is necessary to run this command !cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc inside vim, it just copy a .vimrc to home user.
I close and opened vim and :Explore, Hexplore, Vexplore worked.
I had the same problem as well. Since it's a fresh install of Vim you don't have a .vimrc (or _vimrc on Windows). A vimrc is Vim's configuration file, and once you have one Vim will no longer try to be compatible with Vi (usually what you want).
So all you have to do is create a vimrc file and you should be ready to :Explore all you want. Below are locations you can put your vimrc file, and the filename to use for it. (depending on your system)
Unix/Linux/OSX: $HOME/.vimrc or $HOME/.vim/vimrc
MS-Windows: $HOME/_vimrc, $HOME/vimfiles/vimrc
or $VIM/_vimrc
sources:
* :help 'compatible'
* :help 'vimrc'
I also recommend following atomsfat's answer as well to give you a simple vimrc to start out with.
Those commands are provided by the netrw plugin. Check :scriptnames to see if that plugin is loaded.
I have multiple plugins in Vim and some of them modify the default behavior of Vim. For example I use Vimacs plugin, which makes Vim behave like emacs in the insert mode alone. Sometime I want to turn off the Vimacs plugin without moving the vimacs.vim out of the plugins directory. Is there a way to do it?
You can do this if you use a plugin manager like Vundle or Pathogen, which will keep the plugin in its own directory underneath the ~/.vim/bundle/ directory.
In that case, just find out the runtimepath of the vimacs plugin with the following command:
set runtimepath?
Let's say it's ~/.vim/bundle/vimacs.
Then, put this command in your .vimrc:
set runtimepath-=~/.vim/bundle/vimacs
To load vimacs, just comment that line out and relaunch Vim (or source your .vimrc).
See which variable vimacs check on start. On the begin of the script file find something Like if exists('g:vimacs_is_loaded").... Then set this variable in your .vimrc or while start vim with vim --cmd "let g:vimacs_is_loaded = 1".
In case you are using pathogen, this post gives a better answer, in my opinion. Since I have frequent need to disable snippets when using latex, also added this in my ~/.config/ranger/rc.conf:
map bs shell vim --cmd "let g:pathogen_blacklist = [ 'ultisnips', 'vim-snipmate' ]" %f
This way, whenever I want to open a file with snippets disabled, it is easy.