Один способ использовать Perl (мой выходной язык cal
команда является испанской, но я надеюсь, что результат не варьируется с английского языка):
$ cal | perl -pe 'if ( m/\A\s*\d/ ) { s/\A/++$i . qq[ ] x 2/e } else { s/\A/qq[ ] x 3/e }'
Вывод:
enero de 2012
lu ma mi ju vi sá do
1 1
2 2 3 4 5 6 7 8
3 9 10 11 12 13 14 15
4 16 17 18 19 20 21 22
5 23 24 25 26 27 28 29
6 30 31
Объяснение:
-pe # For every input line from previous pipe, execute next
# instructions and print to output.
if ( m/\A\s*\d/ ) # If line begins with a digit omitting spaces...
s/\A/++$i . qq[ ] x 2/e # Insert at the beginning of the line a counter plus two spaces.
else # else...
s/\A/qq[ ] x 3/e # Insert three spaces at the beginning of the line.
Можно использовать что-то вроде этого в Вашем ~/.vimrc
корректироваться к использованию располагает с интервалами/снабжает вкладками как соответствующее:
" By default, use spaced tabs.
set expandtab
" Display tabs as 4 spaces wide. When expandtab is set, use 4 spaces.
set shiftwidth=4
set tabstop=4
function TabsOrSpaces()
" Determines whether to use spaces or tabs on the current buffer.
if getfsize(bufname("%")) > 256000
" File is very large, just use the default.
return
endif
let numTabs=len(filter(getbufline(bufname("%"), 1, 250), 'v:val =~ "^\\t"'))
let numSpaces=len(filter(getbufline(bufname("%"), 1, 250), 'v:val =~ "^ "'))
if numTabs > numSpaces
setlocal noexpandtab
endif
endfunction
" Call the function after opening a buffer
autocmd BufReadPost * call TabsOrSpaces()
Для этого есть множество плагинов, например (, начиная с моего собственного):