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

66610Re: Does b:undo_ftplugin actually work?

Expand Messages
  • Gary Johnson
    Oct 1, 2012
    • 0 Attachment
      On 2012-09-28, ZyX wrote:

      > > I'm just looking for a way to reset those local options when I edit
      > > a new file, b:undo_ftplugin seemed to be the way to do it, but it
      > > doesn't seem to do anything useful.
      > >
      > > Not using :edit is not a solution. For example, if I start vim
      > > and use ":MRU" to open a recently-used C file, I wind up with
      > > 'indentexpr' set as above, which wrongly indents C.
      > Unset 'indentoptions' on any filetype event, adding definition of
      > needed autocommand somewhere at the beginning of the vimrc (as it
      > is the first file sourced), definitely before “filetype plugin
      > indent on” or similar command, it should not interfere with
      > ftplugins then. Use 'autoindent' instead of your 'indentexpr', it
      > is here just for that reason.

      Here is the current solution, which has been working fine so far
      today. (I explained in a separate post how 'autoindent' does not
      behave the same as this 'indentexpr'.)

      au BufWinEnter * if &ft == "" || &ft == "text"
      \ | setlocal indentexpr=indent(prevnonblank(v:lnum-1))
      \ | setlocal indentkeys-=o
      \ | let b:undo_indent = "setlocal indentexpr< indentkeys<"
      \ | endif
      au FileType * setlocal indentexpr< indentkeys<

      Thanks for your help.


      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
    • Show all 23 messages in this topic