0

在我的 VIM 中,我所有的选项卡都是 2 个空格。但是当我推送到 github 时,它们被转换为 4 个空格。谁能帮我弄清楚如何防止它们转换为 4 个空格?

我的 vimrc 文件:

call pathogen#infect()
call pathogen#runtime_append_all_bundles()

" search
set hlsearch                  " highlight the search
set incsearch                 " incremental search
set ignorecase                " search ignoring case
set showmatch                 " show matching bracket

" colors
set background=dark
let g:solarized_termcolors=8 " proper solarized coloring
colorscheme peachpuff

" syntax
syntax on
filetype on                   " Enable filetype detection
filetype plugin on            " Enable filetype-specific plugins
filetype indent on            " Enable filetype-specific indenting

set ruler                     " show the line number on the bar
set more                      " use more prompt
set autoread                  " watch for file changes
set number                    " line numbers
set hidden
set noautowrite               " don't write old file out when switching files
set lazyredraw                " don't redraw when don't have to
set showmode
set showcmd
set nocompatible              " vim, not vi
set autoindent smartindent    " auto/smart indent
set smarttab                  " tab and backspace are smart
set tabstop=2                 " 6 spaces
set shiftwidth=2
set scrolloff=5               " keep at least 5 lines above/below
set sidescrolloff=5           " keep at least 5 lines left/right
set history=200
set backspace=indent,eol,start
set linebreak
set cmdheight=2               " command line two lines high
set undolevels=1000           " 1000 undos
set updatecount=100           " switch every 100 chars
set complete=.,w,b,u,U,t,i,d  " do lots of scanning on tab completion
set ttyfast                   " we have a fast terminal
set noerrorbells              " No error bells please
set shell=bash
set fileformats=unix
set ff=unix
set wildmode=longest:full
set wildmenu                  " menu has tab completion
set laststatus=2
set diffopt=filler,iwhite     " ignore all whitespace and sync

" scss formatting
autocmd BufRead,BufNewFile *.scss ""set ft=scss.css

" jade formatting
autocmd BufRead,BufNewFile *.jade setlocal ft=jade noexpandtab
autocmd FileType jade :setlocal sw=2 ts=2 sts=2

autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd Filetype javascript setlocal ts=2 sw=2 sts=0 noexpandtab
4

2 回答 2

3

制表符的标准表示是 8 个空格。实际上,制表符是一个控制字符,因此没有关联的字形或设置的宽度。这允许大多数程序提供一种方法来修改它的显示方式,但没有程序会改变它的宽度,因为它没有一个开头:一个选项卡仍然是一个选项卡,无论tabstop.

您的 Vim 设置只会改变选项卡在 Vim 中的显示方式:它们与它们在 Vim 之外的显示方式无关。

你有两个解决方案:

  • 将 GitHub 和 Vim 设置为使用相同的选项卡宽度

  • 使用空间


既然我们在这……</p>

set background=dark
let g:solarized_termcolors=8 " proper solarized coloring
colorscheme peachpuff

如果您不使用日晒线并且set background无用,您可以删除它,因为您的配色方案会处理这一点。

set noautowrite

也无用,因为autowrite默认情况下是关闭的。

call pathogen#runtime_append_all_bundles()

没有任何目的。

于 2013-09-29T06:52:29.460 回答
0

我建议阅读这篇关于如何更改Github的 tabsize 的文章

似乎有一个名为 Stylish 的浏览器扩展,它通过下载样式“代码中尺寸更大的选项卡”来更改 Github 中的选项卡

下载浏览器扩展并使用样式并将选项卡间距更改为两个空格选项卡。

希望这有帮助!

于 2013-09-29T06:39:32.093 回答