Can't get "syntax on" to work in my gvim - syntax

(I'm new to Linux and Vim, and I'm trying to learn Vim but I'm having some issues with it that I can't seen do fix)
I'm in a Linux installation (Ubuntu 8.04) that I can't update, using Vim 7.1.138.
My vim installation is in /usr/share/vim/vim71/. /home/user/
My .vimrc file is in /home/user/.vimrc, as follows:
fun! MySys()
return "linux"
endfun
set runtimepath=~/.vim,$VIMRUTNTIME
source ~/.vim/.vimrc
And then, in my /home/user/.vim/.vimrc:
" =============== GENERAL CONFIG ==============
set nocompatible
syntax on
" =============== ENCODING AND FILE TYPES =====
set encoding=utf8
set ffs=unix,dos,mac
" =============== INDENTING ===================
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)
" =============== FONT ========================
" Set font according to system
if MySys() == "mac"
set gfn=Bitstream\ Vera\ Sans\ Mono:h13
set shell=/bin/bash
elseif MySys() == "windows"
set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
set gfn=Inconsolata\ 14
set shell=/bin/bash
endif
" =============== COLORS ======================
colorscheme molokai
" ============== PLUGINS ======================
" -------------- NERDTree ---------------------
:noremap ,n :NERDTreeToggle<CR>
" =============== DIRECTORIES =================
set backupdir=~/.backup/vim
set directory=~/.swap/vim
...fact is the command syntax on is not working, neither in vim or gvim. And the strange thing is: If I try to set the syntax using the gvim toolbat, it works. Then, in normal mode in gvim, after activating using the toolbar, using the code :syntax off, it works, and just after doing this trying to do :syntax on doesn't work!!
I have the syntax files in both /usr/share/vim/vim71/ and home folders (in the home there's only a python syntax module). I've run sudo aptitude install vim as well and there's nothing do download, EXCEPT vim-gtk, since I was afraid of some kind of incompatibility.
What's going on? Am I missing something?

Let's break this down into something simple. Instead of trying to debug multiple possible points of failure (source, runtimepath), see if the simplest case works. Then, add back in each piece until something breaks.
First of all, make sure your ~/.vimrc/ and ~/.vim/.vimrc are checked into version control or save off a copy. Also, unless you've modified the original python syntax module for some reason, there should be no need to have it located in your ~/.vim directory.
Now, delete the contents of both .vimrc files and add only the following two lines to your ~/.vimrc file.
filetype plugin on
syntax on
Now, open up a new vim session with the file you're trying to syntax highlight. Does it work? I would expect this to work in most cases if the filetype is being detected properly.
:set filetype?
If the syntax highlighting isn't working and the filetype is correct there's something more wrong than just your .vimrc files. You could try removing your ~/.vim directory too to see if that's the problem.
I'm not sure why you're setting your runtimepath but when I check mine, it shows ~/.vim as the first entry (and there are a lot more directories than just VIMRUNTIME) by default so that line shouldn't be necessary.
:set runtimepath?
Also, VIMRUNTIME is misspelled. I expect this is your problem. If I use your set runtimepath from above, I lose syntax highlighting as well.
Hope this helps.

Ubuntu default install doesn't install all of vim.
sudo apt-get install vim

Try adding filetype plugin on before syntax on in your .vimrc.

Related

Vim does not execute plugins in editor, only in application

I am on windows 10. I set up my files like this.
~/.vimrc
set nocp
source ~/vimfiles/autoload/pathogen.vim "location of my pathogen.vim
call pathogen#infect()
call pathogen#helptags()
autocmd vimenter * NERDTree
syntax on
filetype plugin indent on
~/vimfiles/autoload/pathogen.vim
~/vimfiles/bundle/nerdtree
When I open via the desktop application Vim I can use the :NerdTree command okay, I can also use other pluings, but when I open the vim editor from git bash or cmd.
One thing to note is that I do not need the autocmd vimenter command to run :NERDTree in Vim application, but it errors when I try to open :NerdTree from the vim editor.
Any ideas for what I can check?
On Windows, Vim expects your vimrc to be in either of these two locations:
%UserProfile%\_vimrc (note that it's a _, not a .),
%UserProfile%\vimfiles\vimrc (note that there's no _ or . anymore).
The latter is generally recommended because it allows you to keep all your Vim stuff under a single, easy to move around, directory.
Once you have moved your vimrc to a correct location you can remove the first line which is completely useless as Vim sets the nocompatible option itself when it finds a vimrc at an expected location.
See :help vimrc and :help 'nocompatible'.
The second line is also useless because lines 3 and 4 use a feature called "autoloading" through which Vim already knows where to find those functions.
See :help autoload.

Finding config file (vimrc?) for VimR OSX

For the VimR OSX app, I want to change the default vim settings (like default colorscheme, or always having :set number), and read online that there's a vimrc file that should be changed, but for some reason I just can't find it on my computer.
Do you guys know where the vimrc (or whatever the vim config file is called) for VimR is?
Thanks!
VimR, (now?) tracking NeoVim, not Vim, isn't using ~/.vimrc by default any more:
User: I reinstalled VimR recently, and settings from my .vimrc are no longer loaded. Should I create some new dotfile and source .vimrc in it?
Author: NeoVim changed that: https://neovim.io/doc/user/nvim.html#nvim-from-vim
and to quote from the linked NeoVim docs:
Transitioning from Vim *nvim-from-vim*
To start the transition, create ~/.config/nvim/init.vim with these contents:
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
Note: If your system sets `$XDG_CONFIG_HOME`, use that instead of `~/.config`
in the code above. Nvim follows the XDG |base-directories| convention.

Windows gVim 7.3 is creating unexpected folders when opening a file

My setup is:
Windows7 SP1 (Enterprise)
gVim 7.3
Whenever I open a file, Gvim will create 2 folders in the same folder as the file is located. The folders' names are Files and (x86). This only started happening recently. Any idea what could be causing this?
My _vimrc files is as follows
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
behave xterm
set ic
set nu
set ai
set noswapfile
set nobackup
source $VIMRUNTIME/colors/darkblue.vim
set expandtab " expand tabs
set shiftwidth=3
set softtabstop=3
set ruler " show the cursor position all the time
source $VIMRUNTIME/plugin/linuxsty.vim
Do you have any plugins installed? Then try running without them (--noplugin argument), also try a plain Vim gvim -N -u NONE.
It looks like some plugin doesn't do proper quoting of an argument.
You can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for suspect commands.

Can't get vim-ruby to work correctly on Git Bash

I installed vim-ruby on Windows by downloading and running the installation script. I have Git-bash and its own packaged vim.
My problem is that I believe indentation and syntax isn't correct. First of all, right after installation I had a tabstop of 8, a shiftwidth of 8 and noexpandtab. I expected ts=2, sw=2, sts=2 and et.
Also, auto-indentation seems to be simply 'autoindent', when I go to a new line vim simply indents as much as the previous line.
I have checked that the filetype is "ruby", and I have copied the files to the correct directory for Windows ($HOME/vimfiles/). I added a line to my _vimrc for the tabstops and the like, but I am getting the feeling that I'm doing something wrong.
Do you have
filetype plugin indent on
(especially indent) in your vimrc? Also note that vim own indentation script for ruby may come in your way, be sure the installation path for vim-ruby plugin appears before default path.
By the way, what files did you copy and where? You should have ~/vimfiles/indent/ruby.vim with this content after installation.

Vim: Change start up directory?

When I start GVim and start writing my little program I'd like to save the file to the Desktop but it seems that Vim is starting the command line in:
C:\Windows\System32
How would I go about changing that to:
C:\Users\Casey
so then I could just:
:w Desktop\my_program.py
Assuming you're starting gvim from an icon/shortcut in Windows (from the kind of paths you supply), you can change the starting directory (completely independent from the fact that it IS gvim: it would be the same from any other app!) by editing the "starting directory" property of that Windows icon/shortcut.
Within vim, you can change the current directory with the :cd command:
:cd c:\users\casey
I found this way to be better:
Open gVim
:cd $vim
:e _gvimrc
Add the following line:
:cd c:\users\user\desktop\
I found that :Ex is slow on large directories like c:\windows\system32\ (where gVim usually starts).
Also, here is my full _gvimrc in case anyone is interested. I prefer Consolas for coding. The tabstop setting helps when coding especially in Python, and Ctrl+Tab/Ctrl+Shift+Tab is great for switching between buffers:
set guifont=Consolas:h12:cANSI
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
map <C-Tab> :bnext<cr>
map <C-S-Tab> :bprevious<cr>
:cd c:\users\user\desktop\
How about changing your starting position?
vim icon -> right click -> property -> shortcut -> Start in -> your path you want to change.
but it works perfectly.
I think :cd yourpath also works. but it will change when you don't want to change.
Use :cd c:\users\casey,
after that save into session (in gVim there is button up and down in red, click on it and save as mySessionProject.vim). Next time you need to go to that directory, open that session (you can also use :source mySessionProject.vim)
for command line:
:mksession! yourdir/yourVimConfName.vim
to load
:source yourDir/yourVimConfName.vim
I found the following to be very useful. I am on Windows 7 and vim 7.3.46, and am using gVim.
I edited startup settings, which wound up altering the _vimrc in c:\Users\me\.
I also tried using :version and editing the _vimrc files I found at $VIM, as well as the _vimrc I found at c:\windows\system32.
Editing those files to include :cd c:\Users\me did not result in my default startup directory changing after starting vim. I wanted my default directory to be c:\Users\me\, and editing c:\Users\me\_vimrc achieved that. That is I entered
:e $MYVIMRC
and added
cd c:\Users\cnorton.Arlington1\
to that file.
Just to to put this up incase anyone needs it:
vimrc accepts enironmental parameters. you can put cd $USERPROFILE in your vimrc
Use this mapping in your .vimrc file
:cd $USERPROFILE\Desktop<cr>
or the same shorter
cd ~\Desktop<cr>
A mapping that also displays afterwards the path instead of the command
nmap <leader>d :cd ~\Desktop<cr>:pwd<cr>
Inside init.vim, I use:
lcd $HOME/Projects

Resources