How to vim recognize ssh config file?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to vim recognize ssh config file?

Peng Yu
Hi

vim recognize ~/.ssh/config. But I'd like to recognize it in a none
standard location via some file extension. Is there a standard file
extension that will make vim recognize it in a none standard location?
Thanks.

--
Regards,
Peng

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Gary Johnson-4
On 2018-12-20, Peng Yu wrote:
> Hi
>
> vim recognize ~/.ssh/config. But I'd like to recognize it in a none
> standard location via some file extension. Is there a standard file
> extension that will make vim recognize it in a none standard location?
> Thanks.

Vim recognizes only the patterns ssh_config and */.ssh/config.
(Open $VIMRUNTIME/filetype.vim and search for ssh.)  There are
several ways to add your own non-standard pattern for a filetype.
See ":help new-filetype".  I use the method of paragraph C.2: Create
the file ~/.vim/filetype.vim and put the following in it, where the
pattern I've shown as "config.ssh" can by anything you want.

    if exists("did_load_filetypes")
      finish
    endif
    augroup filetypedetect
      au! BufNewFile,BufRead config.ssh setf sshconfig
    augroup END

That said, and since you don't seem to care what the file is named,
it might be easiest to just name your file ssh_config.

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Grant Taylor-2
In reply to this post by Peng Yu
On 12/20/18 5:27 PM, Peng Yu wrote:
> Hi

Hi,

> vim recognize ~/.ssh/config. But I'd like to recognize it in a none
> standard location via some file extension. Is there a standard file
> extension that will make vim recognize it in a none standard location?
> Thanks.

I don't know the nuances of file type detection.  But I do know that you
can easily set it for any arbitrary file by running the following command:

:set syntax=sshconfig

If you support mode lines (?) you can add that.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Tony Mechelynck
On Fri, Dec 21, 2018 at 3:39 AM 'Grant Taylor' via vim_use
<[hidden email]> wrote:

>
> On 12/20/18 5:27 PM, Peng Yu wrote:
> > Hi
>
> Hi,
>
> > vim recognize ~/.ssh/config. But I'd like to recognize it in a none
> > standard location via some file extension. Is there a standard file
> > extension that will make vim recognize it in a none standard location?
> > Thanks.
>
> I don't know the nuances of file type detection.  But I do know that you
> can easily set it for any arbitrary file by running the following command:
>
> :set syntax=sshconfig
>
> If you support mode lines (?) you can add that.

Normally you set 'filetype', not 'syntax'. The difference is that
'filetype' sources the appropriate filetype-plugin(s) (which declare
filetype-specific mappings, etc.); if filetype indenting is on it also
sources the appropriate indent script, and in addition to all that it
sets 'syntax' to the value of 'filetype' in order (if syntax
highlighting is on) to setup the syntax highlighting. Setting only
'syntax' would set the syntax highlighting but not the mappings and
(even if you have used "filetype indent on") not the filetype-specific
indenting.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Tony Mechelynck
On Fri, Dec 21, 2018 at 3:53 AM Tony Mechelynck
<[hidden email]> wrote:

>
> On Fri, Dec 21, 2018 at 3:39 AM 'Grant Taylor' via vim_use
> <[hidden email]> wrote:
> >
> > On 12/20/18 5:27 PM, Peng Yu wrote:
> > > Hi
> >
> > Hi,
> >
> > > vim recognize ~/.ssh/config. But I'd like to recognize it in a none
> > > standard location via some file extension. Is there a standard file
> > > extension that will make vim recognize it in a none standard location?
> > > Thanks.
> >
> > I don't know the nuances of file type detection.  But I do know that you
> > can easily set it for any arbitrary file by running the following command:
> >
> > :set syntax=sshconfig
> >
> > If you support mode lines (?) you can add that.
>
> Normally you set 'filetype', not 'syntax'. The difference is that
> 'filetype' sources the appropriate filetype-plugin(s) (which declare
> filetype-specific mappings, etc.); if filetype indenting is on it also
> sources the appropriate indent script, and in addition to all that it
> sets 'syntax' to the value of 'filetype' in order (if syntax
> highlighting is on) to setup the syntax highlighting. Setting only
> 'syntax' would set the syntax highlighting but not the mappings and
> (even if you have used "filetype indent on") not the filetype-specific
> indenting.

P.S. And regardless of whether you set 'filetype' or 'syntax', use
:setlocal, not plain :set, in order to avoid setting the default for
new files you write from scratch (the global default should be empty).
>
> Best regards,
> Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Grant Taylor-2
In reply to this post by Tony Mechelynck
On 12/20/18 7:53 PM, Tony Mechelynck wrote:
> On Fri, Dec 21, 2018 at 3:39 AM 'Grant Taylor' via vim_use
> <[hidden email]> wrote:
>
> Normally you set 'filetype', not 'syntax'.

Facepalm.  You are correct.  That's what I meant.  I quickly edited
~/.ssh/config, ran :set, and looked for "ssh".  I wondered about
"syntax", but didn't wonder enough to look a few lines below for:

filetype=sshconfig

Sorry.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to vim recognize ssh config file?

Grant Taylor-2
In reply to this post by Tony Mechelynck
On 12/20/18 7:56 PM, Tony Mechelynck wrote:
> P.S. And regardless of whether you set 'filetype' or 'syntax', use
> :setlocal, not plain :set, in order to avoid setting the default for
> new files you write from scratch (the global default should be empty).

Duly noted.

Thank you for the explanation in the last email and the clarification in
this email Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.