Help with update vim file-syntax relationship?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with update vim file-syntax relationship?
# 1  
Old 11-23-2011
Question Help with update vim file-syntax relationship?

There are some ksh files named as "*.lib" in my system. When I open them in VIM, vim syntax can't parse it correctly.

Is there a way that I can relate the *.lib with KSH syntax in VIM?

Due to access limitation, i can only update the files under my home directory and can't modify the VIM package files.

Thanks in Adv.

Regards
# 2  
Old 11-23-2011
You can put a comment somewhere in your files like
Code:
# vim:syntax=sh

When vim reads the file it processes this line and turns on sh syntax.
# 3  
Old 11-23-2011
Bug

Quote:
Originally Posted by hergp
You can put a comment somewhere in your files like
Code:
# vim:syntax=sh

When vim reads the file it processes this line and turns on sh syntax.
Thanks for your answer and it works.

But the sad thing is the "*.lib" files are some source file in a version control system and some extra code is not welcomed. Smilie

Is there a way I can add some config under .vim directory for this issue?
# 4  
Old 11-23-2011
You can put this line into your ~/.vimrc file.
Code:
autocmd BufRead,BufNewFile *.lib set filetype=sh

# 5  
Old 11-23-2011
Quote:
Originally Posted by hergp
You can put this line into your ~/.vimrc file.
Code:
autocmd BufRead,BufNewFile *.lib set filetype=sh

Doesn't work this time. Smilie

Tried to add this line to .vimrc, but seems some syntax error is report...
Maybe need to take a look at the vimrc syntax

Also, i would like to only change *.lib to sh, not all the files. Above command seems do a general change, doesn't it?
# 6  
Old 11-23-2011
What vim version are you using? It works here with vim 7.2 on Solaris.

The command should only associate *.lib files with the sh filetype. See: Vim documentation: autocmd

---------- Post updated at 11:13 ---------- Previous update was at 11:08 ----------

Does this work for you?
Code:
au BufRead,BufNewFile *.lib set syntax=sh

# 7  
Old 11-23-2011
MySQL

Quote:
Originally Posted by hergp
What vim version are you using? It works here with vim 7.2 on Solaris.

The command should only associate *.lib files with the sh filetype. See: Vim documentation: autocmd

---------- Post updated at 11:13 ---------- Previous update was at 11:08 ----------

Does this work for you?
Code:
au BufRead,BufNewFile *.lib set syntax=sh

It does works!! Great thanks for your help.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reapplying syntax highlighting in vim

I had a bash script (ma_report.sh) that I was editing when my VPN connection died. So, when I reconnected, I recovered my changes and reopened the file. Everything looks fine except that there is no longer any syntax highlighting. Using ':syntax on' does not work. Other bash scripts in vim do... (1 Reply)
Discussion started by: treesloth
1 Replies

2. UNIX for Dummies Questions & Answers

Identify process/file relationship

Hey guys. So, I've got an issue on my Debian box. Problem is I ran out of disc space as a process (?) has been creating millions of folders in one place which has led to me having 0 bytes of free space and started messing with my ability to get online, I believe this is to do with INODES? I... (3 Replies)
Discussion started by: 3therk1ll
3 Replies

3. AIX

[Vim] Question about syntax highlighting

Hi all, my sysadmin installed Vim packages (vim-enhanced-6.3-1 & vim-common-6.3-1) on an Aix system (7.1.0.0). I log in using Putty (vs 0.54) and got an annoying underline issue. All strings and var names are underlined as you can see on the attached file Is it possible to get rid of that... (4 Replies)
Discussion started by: Fundix
4 Replies

4. UNIX for Dummies Questions & Answers

error starting vim after an update?

After trying to make an update to my vim settings, i'm now getting this error message when vim tries to start. Any suggestions would be much appreciated :) Error detected while processing .vimrc: line 40: E15: Invalid expression: E15: Invalid expression: (0 Replies)
Discussion started by: khoges11
0 Replies

5. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

6. UNIX for Dummies Questions & Answers

Syntax coloring for .pc files in VIM editor

Hi, i am using VIM editor through Putty. By the option of Syntax on in .vimrc file i am able to see syntax colors in .c and .cpp files but not in the files with .pc extension. How can this be done? :confused: (2 Replies)
Discussion started by: RuchK
2 Replies

7. OS X (Apple)

vim and syntax max os

Hi how to color syntax in terminal in OS X ? I wrote in .vimrc: if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif syntax on and no results. Best regards (1 Reply)
Discussion started by: kezzol
1 Replies
Login or Register to Ask a Question