Vim 8.1 syntax highlighting has disappeared - vim

I use script files with gvim to set syntax to html for files that don't have the extension 'html', but which contain html.
Eg script file contains 'set syntax=html'.
When file is edited: gvim -S scriptfile.txt myfile.txt, the syntax highlighting no longer appears. I say 'no longer' because I've been doing this for years and suddenly (Win10, Vim 8.1) it has stopped... Within the edit, ':set' returns 'syntax=html' - but no syntax highlighting. Must have screwed up something subtle, but what? Thanks for any help.

Went back to the default "c:\Program Files (x86)\vim_vimrc", instead of copying mswin.vim to that location. All's well.

Related

How to get to long directory quickly when writting code in VIM

I am writing Bash script using VIM. I need to cd to a directory and run the command tool. The command tool is deep inside the directory. How do I quickly cd to that directory instead of manually typing the directory out in VIM ? In terminal prompt, I can get to the directory quickly using tab. It does not work in VIM.
Thanks
ffl3883
You can change to the currently edited file's directory with :cd %:h; see :help filename-modifiers. Likewise, if you trigger the tool from Vim :! % can do this quickly (and repeat with :!!). Or just :set autochdir, so that the current directory within Vim always follows the currently edited file (and you can then just reference the file via ./).
When typing file paths in vim (as I often do for shell scripts), I find filename-complete invaluable. Simply type <C-X><C-F> in insert mode.
N.B. It does not work in all cases (generally vim prefers the path to be a separate WORD), but a quick edit-complete-fixup isn’t terrible.

How to open files from within Vim

I am trying to learn how to use Vim. Apparently I have failed at the first hurdle since Vim (certainly on my computers) cannot open files from within itself. I know this must somehow be a mistake on my part since how can Vim still be around with such a flaw??
Anyway I have searched for the last day or so with no solution.
I have tried:
:e .
And Vim helpfully tells me that: "." is a directory. I was under the impression that this command would open a file browser in current directory, but it doesn't.
Similarly I have attempted other commands:
:Ex
:Explore
:Sexplore
:Sex
:Vexplore
:Vex
:Hexplore
:Hex
I have tested these from How do you open a file from within Vim? but nothing suggested there works.
All of these produce: E492: Not an editor command: <insert any of the above commands here>.
I am left with the conclusion Vim can't open files unless Vim is called from the terminal and the file is passed as an argument or the files happen to be in the current directory (where ever that may be) and you know the file's name.
Can someone help? I would like to be able to open files in other directories and list them but for the life of me nothing is working despite every guide I have read saying it would.
Thanks.
At the request from Zaffy this question has been solved.
At Robby Cornelissen's prompting I checked the MX's Linux's package manager and found that vim-common was installed but weirdly not vim. Once I'd installed vim :e . worked and I can now navigate the filesystem.
I have no idea the difference between vim-common and vim or the reason for the separate packages; Robby Cornelissen suggests that vim-common is probably a minimal or tiny version of vim.

Vim 7.4 on Windows 8.1 Creates Program and Files Folders Every Time I Open a File

When I open a file from Windows Explorer using right-click -> Edit with Vim, Vim creates a "Program" folder on the root, and a "Files" folder in the directory of the file I've opened. The Files folder includes Vim/vimfiles/doc. There are no files anywhere, just the directory tree.
This also happens when I run Vim without a file name as an argument.
A DOS Box flashes just before Vim opens, but it goes away too fast for me to read what it's saying.
I've used Vim for years and have never seen this behavior. This is the first time, however, that I've used it on Windows 8.1.
Any suggestions or ideas? I'm getting really tired of deleting Program and Files folders all over the place. Lol!
You could follow the steps on Vim-FAQ 2.5. Some relevant parts follows:
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).
If the problem does not occur, when only loading your .vimrc file, the
error must be caused by a plugin or another runtime file (indent
autoload or syntax script). Check the output of the :scriptnames
command to see what files have been loaded and for each one try to
disable each one by one and see which one triggers the bug. Often
files that are loaded by vim, have a simple configuration variable to
disable them, but you need to check inside each file separately.
There is additional information on the link if the steps above doesn't solves the problem.

file format issue with vim 7.4?

I have this line of code in .vimrc :
au BufRead *.xlsx exec "echo 'xxx'"
And when I open a .xlsx file in vim 7.3 ( I know it's weird to open such a file in vim ), it did echo xxx to me.
But after I upgraded vim to 7.4 and did the same thing, it didn't echo anything to me now.
I've tested it in several machines getting the same result, so I wonder what feature in 7.4 causes this , and what can I do to make it echo what I want like before?
I see that you've figured out the culprit already in the comments (thanks Ben!).
This is caused by version v27 of the zip plugin that ships with Vim 7.4. Its change log reads:
(Jason Spiro) provided a lot of new extensions that are synonyms for .zip
And in fact, the new MS Office file formats (ending with x) are all XML-based ZIP files (whereas the previous ones were in a proprietary binary format).
Fortunately, the plugin allows to override the default file extensions that are considered. You can remove the Office ones from the following list and put that into your ~/.vimrc:
:let g:zipPlugin_ext= '*.zip,*.jar,*.xpi,*.ja,*.war,*.ear,*.celzip,*.oxt,*.kmz,*.wsz,*.xap,*.docx,*.docm,*.dotx,*.dotm,*.potx,*.potm,*.ppsx,*.ppsm,*.pptx,*.pptm,*.ppam,*.sldx,*.thmx,*.xlam,*.xlsx,*.xlsm,*.xlsb,*.xltx,*.xltm,*.xlam,*.crtx,*.vdw,*.glox,*.gcsx,*.gqsx'

Vim - ctags: tag not found

I want to use Ctags for a Zend framework project. I executed this command : ctags -R ./* ../ZendFramework/*to create a list of tags, but the problem is when I press Ctrl-] on a class or method I get this error: ctags: tag not found
I checked the tags file and all classes/methods/variables are listed. The tags files is located in the root of the project. Should I load it manullay when I open a file?
Yes, you should tell Vim where to find your tags file with something like:
:set tags=/path/to/tags
This is not very optimal, though. This line in your ~/.vimrc should help:
set tags=./tags,tags;$HOME
It tells Vim to look for a tags file in the directory of the current file, in the current directory and up and up until your $HOME (that's the meaning of the semicolon), stopping on the first hit.
The 'tags' variable must point to your tags file. See :help 'tags'.
An example to add the path to your tags file:
:set tags+=$HOME/yourpath/tags
I Faced the same problem few days ago. I was applying ctags shortcuts in a .c file and I was getting this error while doing so. I googled the error and found that the ctags was not installed. But the ctags is present in my server. I tried moving the ctag folder to the trunk which i'm currently working and this trick resolved my problem.
steps:
go to your home folder and enter "where is ctags"
it will display the path of the ctags file.
copy that file and move the same to the directory which you are working in
i hope this will resolve your issue.

Resources