From: Jorgen Grahn on 9 Jun 2010 08:30 On Mon, 2010-06-07, Neil Cerutti wrote: > On 2010-06-07, Jean-Michel Pichavant <jeanmichel(a)sequans.com> wrote: >> Hello, >> >> Does anyone knows a way to configure vim so it automatically >> select to correct expandtab value depending on the current >> buffer 'way of doing' ? I need to edit different files, some >> are using spaces, others tabs. Those belong to different >> projects, and changing all spaces to tabs is not an option for >> me. >> >> I can't make vim automatically comply with the current buffer >> coding style, anyone knows if it is possible ? > > :h filetypes will get you started on the right path. It'll be up > to you to program the recognition logic. Do you have a heuristic > in mind? > > You will be better off converting tabbed files to be tabless, > which is pretty easy in vim. But as he wrote, that is not an option. And I can believe that -- if you are many programmers, working in parallel on some fairly big and mature project, the *last* thing you want is someone coming in and reindenting everything. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
From: Robin Becker on 9 Jun 2010 10:20 On 09/06/2010 13:06, Jean-Michel Pichavant wrote: ......... >> the idea is to switch between using tabs and spaces depending on the >> original source. If the input is all spaces we switch to tabs >> internally and then convert on output. If it was tabbed we keep that, >> if mixed I think it keeps that. This works for me as I often work with >> long latency connections and prefer tabs to spaces. > > Thanks, this is no exactly what I needed, but from your code I managed > to write something that suits me. > It basically counts the occurrence of tabs and 4-spaces at the beginning > of lines, and use the greatest number as criterion for setting tab or > space mode > Something usefull is to get also the current mode in the status bar. > > Because of my poor knowledge of the vim scripting language I sometimes > had to switch to python, but I guess it won't bother anyone in this list :) > > > set statusline=%t\ %y\ format:\ %{&ff};\ %{Statusline_expandtab()}\ [%c,%l] > > function! Statusline_expandtab() ....... I'm not exactly an expert at vim programming either :( nice idea to show the mode in the status. -- Robin Becker
First
|
Prev
|
Pages: 1 2 Prev: os.path.normpath question Next: Which objects are expanded by double-star ** operator? |