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.
Related
If I open a file in a current directory using netrw and then reopen the netrw using :Sexplore the netrw window opens below (I have splitbelow set), but the cursor remains in the file being edited and I cannot move to the netrw window using CTRL-W combinations.
Am I doing something wrong or is this a bug?
Steps to reproduce
run vim .
netrw opens, highlight a file in the current directory (let's say test.txt) and press Return, file test.txt opens
run :Sexplore cmd
netrw opens below but the cursor remains in the file opened previously.
My .vimrc
set nocompatible
set splitbelow
VIM version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 8 2015 23:11:08)
MacOS X (unix) version
Included patches: 1-944
This is how it looks like:
I cannot reproduce with version 154a (use :echo g:loaded_netrwPlugin to check your netrw version).
Try with the latest version.
Edit:
It is possible that the problem is cause by some other plugin interference or settings. You could try following the approach described at Vim FAQ 2.5:
2.5. I have a "xyz" (some) problem with Vim. How do I determine it is a
problem with my setup or with Vim? / Have I found a bug in Vim?
First, you need to find out, whether the error is in the actual
runtime files or any plugin that is distributed with Vim or whether it
is a simple side effect of any configuration option from your .vimrc
or .gvimrc. So first, start vim like this:
vim -u NONE -U NONE -N -i NONE
This starts Vim in nocompatible mode (-N), without reading your
viminfo file (-i NONE), without reading any configuration file (-u
NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc
file) or even plugin.
(...)
If the error does not occur when starting Vim this way, then the
problem is either related to some plugin of yours or some setting in
one of your local setup files. You need to find out, what triggers the
error, you try starting Vim this way:
vim -u NONE -U NONE -N
If the error occurs, the problem is your .viminfo file. Simply delete
the viminfo file then. If the error does not occur, try:
vim -u ~/.vimrc --noplugin -N -i NONE
This will simply use your .vimrc as configuration file, but not load
any plugins. If the error occurs this time, the error is possibly
caused by some configuration option inside your .vimrc file. Depending
on the length of your vimrc file, it can be quite hard to trace the
origin within that file.
The best way is to add :finish command in the middle of your .vimrc.
Then restart again using the same command line. If the error still
occurs, the bug must be caused because of a setting in the first half
of your .vimrc. If it doesn't happen, the problematic setting must be
in the second half of your .vimrc. So move the :finish command to the
middle of that half, of which you know that triggers the error and
move your way along, until you find the problematic option. If your
.vimrc is 350 lines long, you need at a maximum 9 tries to find the
offending line (in practise, this can often be further reduced, since
often lines depend on each other).
Obviously you will have to load netrw manually (which can be done by sourcing plugin/netrwPlugin.vim -- if you are using some plugin manager you will have to move the plugin to ~/.vim/ or change your runtime path due to the autoload functions) and set nocompatible and splitbelow.
Actually there is an adapted version of this procedure in :help netrw-debug:
Step 2: assuming that you've installed the latest version of netrw,
check that your problem is really due to netrw. Create a file called
netrw.vimrc with the following contents:
set nocp
so $HOME/.vim/plugin/netrwPlugin.vim
Then run netrw as follows:
vim -u netrw.vimrc --noplugins [some path here]
Perform whatever
netrw commands you need to, and check that the problem is still
present. This procedure sidesteps any issues due to personal .vimrc
settings and other plugins. If the problem does not appear, then you
need to determine what setting in your .vimrc is causing the conflict
with netrw or which plugin.
Step 3: If the problem still is present, then get a debugging trace
from netrw:
(...)
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.
I have installed cvim and NodeTree plugins and generated an exuberant ctags file for my build tree.
This is what my ~/.vim/.vimrc file looks like:
:noremap :TlistToggle
:let Tlist_Show_One_File = 1
:let Tlist_Exit_OnlyWindow = 1
:let Tlist_Use_Right_Window = 1
set tags=./tags;/
set number
set tabstop=4
set incsearch
When I start editing a file, I notice that Ctrl ] does not work and I have to resort to typing ta: funcname - which gets tiring after a while. Interestingly enough, Ctrl T pops me off the tag stack as expected - I don't understand whats going on - how do I fix this?
Incidentally, vim (appears to) completely ignores the contents of my .vimrc file and I always have to type the same commands in the editor, so as to get the settings I want - very annoying.
Last but not the least, I used to be able to type :make in the editor window, drop to the console and then have the build results displayed in a little window which I can then go to and select a line (with an error or warning say), and then have the editor automagically take me to the offending line - unfortunately, I don't remember the plugin (or commands) I used to allow me to build from within vim.
So, how do I:
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
Fix my .vimrc file so that contents are actually applied to my vim session.
Find the appropriate plugin to install to allow builds (using make) from within vim
You're asking about a weird mix of problems.
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
The tags functionality is working; I suspect that you have a mapping blocking Ctrl-]. Try
:verbose nmap <C-]>
and
:nunmap <C-]>
Fix my .vimrc file so that contents are actually applied to my vim session.
:echo $MYVIMRC
will tell you the location of the .vimrc that Vim uses. Also, check the output of :scriptnames which scripts get loaded, and read :help vimrc to understand the logic Vim applies.
Find the appropriate plugin to install to allow builds (using make) from within vim
That's built into Vim. With the appropriate 'makeprg' set (it defaults to make), you can run :make. Vim parses the output (through the 'errorformat' option), and you can open the quickfix list via :copen.
Your vimrc is:
~/.vim/.vimrc
If you run Vim 7.4, it should be:
~/.vim/vimrc
or
~/.vimrc
If you run Vim 7.3 or older, it should be:
~/.vimrc
And... what Ingo said.
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 trying to get the following into my .vimrc
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
Those lines are from here are worked perfectly in vim 7.2
I recently compiled and installed vim 7.3 and now those characters aren't understood by vim.
Also: Ctrl+V then U in insert doesn't let me insert any characters, it just seems to ignore that.
Any ideas?
This is what I see:
set listchars=tab:�~V�\ ,eol:¬
You need to compile vim with multi-byte support.
The easiest way to do this is to run
./configure --with-features=big
make
This will build vim with the correct support.
You can verify that it was compiled correctly with
:version
in vim or by running
vim --version
and looking for +multi_byte. If it says -multi_byte it will not work.
I have the following in my .vimrc
scriptencoding utf-8
set encoding=utf-8
and that in my .gvimrc
set listchars=trail:·,precedes:«,extends:»,eol:↲,tab:▸\
and works fine(notice there is a space after the ▸\ ).
I had the same issue with the vim that ships with OS X Lion although it was compiled with multi_byte.
The issue was the encoding used by vim. I added set encoding=utf-8 in my ~/.vimrc and the issue was solved.
Ref: Terminal Vim redraw issues in OS X Lion
Make sure you're using a compatible font. My problem was that inconsolata-g does not support the utf-8 characters in my document.
also, this was all I needed in my gvimrc:
set enc=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf8,prc
set guifont=Monaco:h14
set guifontwide=NSimsun:h14
I had this issue while being in a screen session.
It's gone with setting the following in my .bashrc:
export LANG=en_US.UTF-8
Don't forget, if you're running vim in a terminal, make sure the terminal itself is using utf-8 as well.
When all else failed, telling vim to save with UTF-8 encoding seemed to work (for now at least):
:write ++enc=utf-8
Do you need a
scriptencoding utf-8
or whatever encoding your .vimrc is actually in?
The accepted answer didn't work for me. Working off of the downloaded source on a Mac running Lion, I went into the src directory and ran:
make clean
export CONF_OPT_MULTIBYTE='--enable-multibyte'
make reconfig
Running: ./vim --version to check for +muti_byte then:
make install
Via: http://vim.1045645.n5.nabble.com/compiling-vim7-1-huge-version-gets-build-with-normal-version-td1162314.html