Loading ...
Sorry, an error occurred while loading the content.

man.vim settings file (manual page browser)

Expand Messages
  • Sung-Hyun Nam
    Hello, I made a manual page browser. You can use this file: copy it to ~/.vim/settings add filetype settings on to .vimrc Now, you can do run vim type :set
    Message 1 of 4 , Sep 3, 2000
    • 0 Attachment
      Hello,

      I made a manual page browser.
      You can use this file:
      copy it to ~/.vim/settings
      add 'filetype settings on' to .vimrc

      Now, you can do
      run vim
      type ':set ft=man'
      type ':Man vim' to see this works.
      Or,
      gvim -c "set ft=man" -c "Man vim"


      Documentation: (Feel free to fix my ugly english).

      *man-filetype*
      The 'iskeyword' includes additional '.' to allow navigate the manual page
      which has dot character.

      Local mappings:
      <Map>h Remove backspace character from the manual page.
      <C-]> The keyword on which the cursor is standing is used as a
      another manual page. With CTRL-] command, you can navigate
      into another manual page.
      <C-T> This will bring you to the previous manual page where you
      hit CTRL-] before.

      User commands:
      Man The ':Man' command works like 'man' command in shell prompt.
      For example: You can bring vim manual page into vim. Just
      type, ':Man vim' and hit return key.


      BUGS:
      It didn't check if the manual page exists or not. So, if the
      manual page does not exists, empty (with error message?) buffer
      will opened.
      I think I can check it using system dependent command such as:
      Linux: /usr/bin/man -w <manual_page>
      Solaris: /usr/bin/man -l <manual_page>
      But, what other system? Is there any good solution?

      regards,

      namsh


      " Vim settings file
      " Language: man
      " Maintainer: Sung-Hyun Nam <namsh@...>
      " Last Change: 2000/09/02

      if exists("b:did_settings")
      finish
      endif
      let b:did_settings = 1

      " allow dot in manual page name.
      setlocal iskeyword+=\.

      nmap <buffer> <Map>h :%s/.\b//g<cr>:set nomod<cr>''

      nmap <buffer> <c-]> :call MAN_GetPage(expand("<cword>"))<cr>
      nmap <buffer> <c-t> :call MAN_PopPage()<cr>

      " Define commands/functions only once.
      if !exists("g:man_tag_depth")

      com! -nargs=1 Man call MAN_GetPage(<q-args>)

      let g:man_tag_depth = 0

      func! MAN_GetPage(f)
      exec "let g:man_tag_".g:man_tag_depth."_buf = ".bufnr("%")
      exec "let g:man_tag_".g:man_tag_depth."_line = ".line(".")
      exec "let g:man_tag_".g:man_tag_depth."_col = ".col(".")
      let g:man_tag_depth = g:man_tag_depth + 1
      setl hidden
      exec "new $HOME/".a:f
      only
      exec "r!/usr/bin/man ".a:f." | col -b"
      " Is it OK? It's for remove blank or message line.
      exec "norm 2G/^[^\s]\<cr>kd1G"
      setl ft=man nomod
      endfunc

      func! MAN_PopPage()
      if g:man_tag_depth > 0
      let g:man_tag_depth = g:man_tag_depth - 1
      exec "let g:man_tag_buf=g:man_tag_".g:man_tag_depth."_buf"
      exec "let g:man_tag_line=g:man_tag_".g:man_tag_depth."_line"
      exec "let g:man_tag_col=g:man_tag_".g:man_tag_depth."_col"
      exec g:man_tag_buf."b"
      exec g:man_tag_line
      exec "norm ".g:man_tag_col."|"
      exec "unlet g:man_tag_".g:man_tag_depth."_buf"
      exec "unlet g:man_tag_".g:man_tag_depth."_line"
      exec "unlet g:man_tag_".g:man_tag_depth."_col"
      unlet g:man_tag_buf g:man_tag_line g:man_tag_col
      endif
      endfunc

      endif
    • Johannes Zellner
      ... Are you sure you re not reinventing the wheel here ? see: http://www.zellner.org/vim/functions/man.vim -- Johannes
      Message 2 of 4 , Sep 3, 2000
      • 0 Attachment
        On Mon, Sep 04, 2000 at 01:36:34PM +0900, Sung-Hyun Nam wrote:
        > Hello,
        >
        > I made a manual page browser.
        > You can use this file:
        > copy it to ~/.vim/settings
        > add 'filetype settings on' to .vimrc
        >
        > Now, you can do
        > run vim
        > type ':set ft=man'
        > type ':Man vim' to see this works.
        > Or,
        > gvim -c "set ft=man" -c "Man vim"

        Are you sure you're not reinventing the wheel here ?
        see: http://www.zellner.org/vim/functions/man.vim

        --
        Johannes
      • Sung-Hyun Nam
        ... Good. It also support sections. But it does not work in solaris. For solaris, man -s section manual_page should be used. I know it works in my Linux box.
        Message 3 of 4 , Sep 3, 2000
        • 0 Attachment
          Johannes Zellner wrote:
          > On Mon, Sep 04, 2000 at 01:36:34PM +0900, Sung-Hyun Nam wrote:
          > > Hello,
          > >
          > > I made a manual page browser.
          > > You can use this file:
          > > copy it to ~/.vim/settings
          > > add 'filetype settings on' to .vimrc
          > >
          > > Now, you can do
          > > run vim
          > > type ':set ft=man'
          > > type ':Man vim' to see this works.
          > > Or,
          > > gvim -c "set ft=man" -c "Man vim"
          >
          > Are you sure you're not reinventing the wheel here ?
          > see: http://www.zellner.org/vim/functions/man.vim

          Good. It also support sections. But it does not work in solaris.
          For solaris, 'man -s section manual_page' should be used.
          I know it works in my Linux box. What about other systems?
          If this works only for few systems, I think removing the feature is
          better.

          So, how about add a browse feature to yours?
          I cannot see the browse feature, I mean 'CTRL-]' and 'CTRL-T'.
          (Because my man.vim's main feature is browsing with <c-]> and <c-t>,
          I think I didn't reinvent the wheel...)

          If you make it to 'settings' compatible(?) - should port it to vim60 -...
          then I guess bram include this to vim60 distribution.
          Then I will use your man.vim settings file happily.

          regards,

          namsh
        • Johannes Zellner
          ... solaris /is/ supported by my script. see the line if $OSTYPE == ├čolaris && !exists( g:man_section_argument ) ... It works for all systems I m on:
          Message 4 of 4 , Sep 4, 2000
          • 0 Attachment
            On Mon, Sep 04, 2000 at 03:52:39PM +0900, Sung-Hyun Nam wrote:
            > Johannes Zellner wrote:
            > > On Mon, Sep 04, 2000 at 01:36:34PM +0900, Sung-Hyun Nam wrote:
            > > > Hello,
            > > >
            > > > I made a manual page browser.
            > > > You can use this file:
            > > > copy it to ~/.vim/settings
            > > > add 'filetype settings on' to .vimrc
            > > >
            > > > Now, you can do
            > > > run vim
            > > > type ':set ft=man'
            > > > type ':Man vim' to see this works.
            > > > Or,
            > > > gvim -c "set ft=man" -c "Man vim"
            > >
            > > Are you sure you're not reinventing the wheel here ?
            > > see: http://www.zellner.org/vim/functions/man.vim
            >
            > Good. It also support sections. But it does not work in solaris.
            > For solaris, 'man -s section manual_page' should be used.
            solaris /is/ supported by my script. see the line

            if $OSTYPE == ├čolaris" && !exists("g:man_section_argument")
            ...

            > I know it works in my Linux box. What about other systems?
            > If this works only for few systems, I think removing the feature is
            > better.
            It works for all systems I'm on:
            SGI/IRIX, DEC/OSF1, HP-UX, NetBSD, Linux.

            > So, how about add a browse feature to yours?
            you can use the mapped key `Q' on any keyword, this includes words in
            an alreay open man page. You can precede Q by a number (count) to get
            the manpage out of the specified section (you can use any mapping
            (in vim6 it would be maplocal), e.g. CTRL-].)
            I've no possibility to jump back though.

            > I cannot see the browse feature, I mean 'CTRL-]' and 'CTRL-T'.
            > (Because my man.vim's main feature is browsing with <c-]> and <c-t>,
            > I think I didn't reinvent the wheel...)
            >
            > If you make it to 'settings' compatible(?) - should port it to vim60 -...
            yes. This would probably be a good idea.

            --
            Johannes
          Your message has been successfully submitted and would be delivered to recipients shortly.