Gary Johnson wrote:
> On 2016-07-26, Bram Moolenaar wrote:
> > James McCoy wrote:
> >
> > > On Mon, Jul 25, 2016 at 07:39:55AM -0700, Ben Fritz wrote:
> > > > On Sunday, July 24, 2016 at 8:03:06 AM UTC-5, Bram Moolenaar wrote:
> > > > >
> > > > > if has("autocmd")
> > > > > " Enable file type detection.
> > > > > filetype plugin indent on
> > > > >
> > > >
> > > > Don't common plugin managers require you to turn on filetype stuff at
> > > > a very specific location, e.g. *after* loading the plugin manager
> > > > functionality?
> > >
> > > By now, most of them do this automatically, but I still advocate against
> > > doing this before the vimrc is loaded since it causes non-obvious
> > > problems to users (and am annoyed that Ubuntu deviates from the way I've
> > > setup Debian's packaging in this regard).
> > >
> > > The reason this needs to be done is to for ftdetect scripts.
> > >
> > > Without doing the equivalent of
> > >
> > > :filetype off
> > > " Setup plugin manager
> > > " Re-run :filetype on, if needed
> > >
> > > any ftdetect scripts located in the runtime paths handled by the plugin
> > > manager wouldn't have their settings applied.
> > >
> > > Now, in Neovim we've enable filetype plugins and indent scripts by
> > > default. However, we also track whether they were enabled
> > > automatically, or modified by the user, so that "filetype plugin on" in
> > > the user's vimrc only enables plugins instead of acting like a no-op.
> > > You can see the discussion of the behavior/implementation at
> > > <https://github.com/neovim/neovim/pull/4223>.
> >
> > Arent't users already executing the filetype command early in their
> > .vimrc?
>
> No. I execute the filetype command late in my vimrc so that some of
> my BufRead autocommands will be executed before Vim's. I want
> buffers to be initially configured by project, which means looking
> at the full path to the file being opened, and then by filetype.
>
> I turn _off_ filetype detection near the top of my vimrc in
> environments where it's been turned on in some system vimrc.
Hmm, this very much depends on what you want to do in your .vimrc.
I think it's still best to enable filetype detection when there is no
.vimrc at all. And I suspect doing what you do, disabling filetype
detection at the start of your .vimrc allows for any sequence that you
choose.
Here is what I have come up with, listenting to the comments so far and
giving it some magic weighing:
" The startup file file.
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 2016 Jul 25
"
" This is loaded very early on startup, execpt with Vim is run with "-u NONE".
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set history=200 " keep 200 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set wildmenu " display completion matches in a status line
" Do incremental searching when it's possible to timeout.
if has('reltime')
set incsearch
endif
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
" confusing.
set nrformat-=octal
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on when the terminal has colors or when using the
" GUI (which always has colors).
if &t_Co > 2 || has("gui_running")
syntax on
" I like highlighting strings inside C comments.
let c_comment_strings=1
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily with:
" augroup vimStartup | au! | augroup END
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
if has('langmap') && exists('+langnoremap')
" Prevent that the langmap option applies to characters that result from a
" mapping. If unset (default), this may break plugins (but it's backward
" compatible).
set langnoremap
endif
--
Dreams are free, but there's a small charge for alterations.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.