Setting Vim to use shell syntax for dotfiles?

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I am creating multiple files (.school_aliases and .git_aliases) to put my aliases in for organization. However, Vim doesn't highlight syntax for these files automatically like for .bashrc or .bash_aliases. Is there a way I could get Vim to do this automatically rather than just doing set syntax=sh?
vim alias dot-files syntax-highlighting
add a comment |Â
up vote
1
down vote
favorite
I am creating multiple files (.school_aliases and .git_aliases) to put my aliases in for organization. However, Vim doesn't highlight syntax for these files automatically like for .bashrc or .bash_aliases. Is there a way I could get Vim to do this automatically rather than just doing set syntax=sh?
vim alias dot-files syntax-highlighting
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am creating multiple files (.school_aliases and .git_aliases) to put my aliases in for organization. However, Vim doesn't highlight syntax for these files automatically like for .bashrc or .bash_aliases. Is there a way I could get Vim to do this automatically rather than just doing set syntax=sh?
vim alias dot-files syntax-highlighting
I am creating multiple files (.school_aliases and .git_aliases) to put my aliases in for organization. However, Vim doesn't highlight syntax for these files automatically like for .bashrc or .bash_aliases. Is there a way I could get Vim to do this automatically rather than just doing set syntax=sh?
vim alias dot-files syntax-highlighting
asked Feb 1 at 19:40
Kevin
11016
11016
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can use the following in your .vimrc:
autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh
Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
1
I changed*.school_aliasesto.*_aliases, and it worked perfectly for all my alias files. Thanks!
â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
add a comment |Â
up vote
1
down vote
Add to each of the files a line, thus:
# vim:syntax=sh filetype=sh
This line is a comment to your shell(s) (as it starts with #), but vim will see it and understand that it should interpret the file as a shell script for the purposes of syntax highlighting et cetera, even though the filename does not end with .sh.
This seems like it's working, but my color scheme doesn't apply as it would when I manually doset syntax=sh...
â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.colorscheme=darkblue).
â DopeGhoti
Feb 1 at 20:10
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use the following in your .vimrc:
autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh
Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
1
I changed*.school_aliasesto.*_aliases, and it worked perfectly for all my alias files. Thanks!
â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
add a comment |Â
up vote
1
down vote
accepted
You can use the following in your .vimrc:
autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh
Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
1
I changed*.school_aliasesto.*_aliases, and it worked perfectly for all my alias files. Thanks!
â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use the following in your .vimrc:
autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh
Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
You can use the following in your .vimrc:
autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh
Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
answered Feb 1 at 19:58
aliceinpalth
760116
760116
1
I changed*.school_aliasesto.*_aliases, and it worked perfectly for all my alias files. Thanks!
â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
add a comment |Â
1
I changed*.school_aliasesto.*_aliases, and it worked perfectly for all my alias files. Thanks!
â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
1
1
I changed
*.school_aliases to .*_aliases, and it worked perfectly for all my alias files. Thanks!â Kevin
Feb 1 at 20:21
I changed
*.school_aliases to .*_aliases, and it worked perfectly for all my alias files. Thanks!â Kevin
Feb 1 at 20:21
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
Glad it worked out!
â aliceinpalth
Feb 2 at 7:48
add a comment |Â
up vote
1
down vote
Add to each of the files a line, thus:
# vim:syntax=sh filetype=sh
This line is a comment to your shell(s) (as it starts with #), but vim will see it and understand that it should interpret the file as a shell script for the purposes of syntax highlighting et cetera, even though the filename does not end with .sh.
This seems like it's working, but my color scheme doesn't apply as it would when I manually doset syntax=sh...
â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.colorscheme=darkblue).
â DopeGhoti
Feb 1 at 20:10
add a comment |Â
up vote
1
down vote
Add to each of the files a line, thus:
# vim:syntax=sh filetype=sh
This line is a comment to your shell(s) (as it starts with #), but vim will see it and understand that it should interpret the file as a shell script for the purposes of syntax highlighting et cetera, even though the filename does not end with .sh.
This seems like it's working, but my color scheme doesn't apply as it would when I manually doset syntax=sh...
â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.colorscheme=darkblue).
â DopeGhoti
Feb 1 at 20:10
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Add to each of the files a line, thus:
# vim:syntax=sh filetype=sh
This line is a comment to your shell(s) (as it starts with #), but vim will see it and understand that it should interpret the file as a shell script for the purposes of syntax highlighting et cetera, even though the filename does not end with .sh.
Add to each of the files a line, thus:
# vim:syntax=sh filetype=sh
This line is a comment to your shell(s) (as it starts with #), but vim will see it and understand that it should interpret the file as a shell script for the purposes of syntax highlighting et cetera, even though the filename does not end with .sh.
answered Feb 1 at 20:02
DopeGhoti
40.4k54779
40.4k54779
This seems like it's working, but my color scheme doesn't apply as it would when I manually doset syntax=sh...
â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.colorscheme=darkblue).
â DopeGhoti
Feb 1 at 20:10
add a comment |Â
This seems like it's working, but my color scheme doesn't apply as it would when I manually doset syntax=sh...
â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.colorscheme=darkblue).
â DopeGhoti
Feb 1 at 20:10
This seems like it's working, but my color scheme doesn't apply as it would when I manually do
set syntax=sh...â Kevin
Feb 1 at 20:09
This seems like it's working, but my color scheme doesn't apply as it would when I manually do
set syntax=sh...â Kevin
Feb 1 at 20:09
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.
colorscheme=darkblue).â DopeGhoti
Feb 1 at 20:10
That's highly unusual. You can set more things on that line if you wish to manually set the color scheme though (e. g.
colorscheme=darkblue).â DopeGhoti
Feb 1 at 20:10
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421279%2fsetting-vim-to-use-shell-syntax-for-dotfiles%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password