On Thu, Feb 23, 2012 at 11:24:41AM -0800, Ben Fritz wrote: > I've got a BufReadPost autocmd in my .vimrc which will automatically > reload a file in DOS or Unix fileformat using e ++ff=dos or e + > +ff=unix if it is in mixed line-ending format, depending on whether > there are more lines with or without a trailing ^M.
> It works well, but I sometimes want to force it to load one way or the > other, with an explicit :e ++ff=unix for example. > So, I'm trying to modify my autocmd to only act if I did not > explicitly specify the fileformat on the command-line. I've tried > using @:, but that does not seem to get updated until after my autocmd > fires. I've tried using getcmdline(), but that is invalid (and returns > an empty string) because the command-line is not currently being > edited when the autocmd fires. > My only other though is to set up a cnoremap <expr> mapping which maps > <CR> to a function which stores off the getcmdline() result to a > variable, then returns "\<CR>", so that it doesn't actually do > anything but allows access to the currently executing command. > I suspect this will work, but is there a better way? i always tend to oversimplify things, and i like to avoid autocommands and plugins -- what i would do is add a variable to your .vimrc that would set or not the ff setting autocommand depending on the value of the variable -- then i would make two copies of all my vim start scripts, one to allow the autocommand, the other to force the ff setting you want sc -- 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
