1

I wasn't sure how to word this properly in the title..

what I'm looking to do is set variables one way or another depending on how vim is invoked. Specifically I have just discovered the Man plugin, and set my shell's manpager to vim.

When invoked as the manpager, I would like vim to use different default options for things like spell and scrolloff .. is this possible?

1

Yes, you can by working with the filetype.

To determine the filetype execute :set ft?

For the displayed man page this returns man.

If you want to set special settings for this filetype create the file ~/.vim/after/ftplugin/man.vim. All settings in this file will be loaded, when you open a man page.

There is already a default ftplugin (read "filetype plugin") for man pages. By placing your file below the subdir .vim/after/ftplugin, the default ftplugin is read first and then your file from the after-directory is read. This is the way to change or extend settings for a existing filetype.

BTW: On Windows it is $HOME/vimfiles/after/man.vim.

See :h after-directory and :help ftplugin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.