Page 1 of 1
VIM syntax highlighting
Posted: Wed Mar 09, 2005 10:48 pm
by Neo(out)
I have a query regrading the symtax highlighting in VIM. I have a normal user access to a remote machine and I have to edit some text files that are actually javascript files. Is there any way i can get the files ending with .txt to highlight as the javascript files for me? I cannto add any syntax files in the syntax dir of vim.
so is there any other way?
Re:VIM syntax highlighting
Posted: Wed Mar 09, 2005 11:06 pm
by mystran
First of all, IIRC you can put all configuration in ~/.vim directory as well as the system-wide directory. So putting a custom systax highlight-script into ~/.vim/syntax/whatever.vim should work.
The second thing is with detecting filetype. Normally I would expect Vim to detect JavaScript when the file-extension is .js
but if you want .txt too, there are couple of options:
- Configure the detection in your .vimrc
- use a comment, with vim:syntax=javascript: in your javascript files
Notice that in order to get syntax highlighting at all, you might need to put the following in your ~/.vimrc:
Code: Select all
" enable syntax high-lighting
syntax on
" enable filetype autodetection
" also detect auto indent..
filetype plugin indent on
If you really want all text files to be detected as Javascript files, you can put the following in your .vimrc:
Code: Select all
autocmd FileType text setlocal syntax=javascript
(at least if I'm not mistaken)
Re:VIM syntax highlighting
Posted: Thu Mar 10, 2005 6:24 am
by Neo
I just found out there I can open the file and then issue the command 'set ft=javascript' to get it to highlight accordingly. Is there any way this command can always be executed when i start VI /VIM
Re:VIM syntax highlighting
Posted: Fri Mar 11, 2005 6:48 am
by Solar
~/.vimrc.
Re:VIM syntax highlighting
Posted: Mon Mar 14, 2005 1:44 pm
by mystran
Urgh.. does this forum still convert "java"+"script" (that is, those words written together without a space between) automatically to Java Script? And if so, is there any sensible reason why this happens? It... kinda annoying every time we need to talk about javascript.
Just asking... not that I really expect a fix.
Re:VIM syntax highlighting
Posted: Tue Mar 15, 2005 5:43 am
by Neo
mystran wrote:
Code: Select all
autocmd FileType text setlocal syntax=Java Script
I had to change that to
Code: Select all
autocmd BufEnter *.txt setlocal ft=javascript