从 Vim 复制到 VSCode 导致额外的制表符
Copy from Vim to VSCode causing extra tab
使用 "+y
将正常缩进的文本从 Vim 复制到系统剪贴板后,我将其粘贴 VSCode。如图所示,制表符缩进的每一行将缩进两个制表符宽度。
Vim中的代码:
VSCode 中的代码复制自 Vim:
shiftwidth
在我的 .vimrc 中设置为 4,制表符大小在 VSCode.
中设置为 4
下面是我的完整 .vimrc:
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'jiangmiao/auto-pairs'
" Theme
Plug 'phanviet/vim-monokai-pro'
Plug 'sainnhe/sonokai'
Plug 'crusoexia/vim-monokai'
Plug 'chriskempson/base16-vim'
" Syntax highlighting
Plug 'sheerun/vim-polyglot'
" Master Vim
Plug 'takac/vim-hardtime'
" Autocomplete
Plug 'ycm-core/YouCompleteMe'
" Full path fuzzy file, buffer, mru, tag, ... finder
Plug 'ctrlpvim/ctrlp.vim'
" Move line
Plug 'matze/vim-move'
" Window
Plug 'tpope/vim-vinegar'
" Status bar
Plug 'vim-airline/vim-airline'
" Git tool
Plug 'tpope/vim-fugitive'
" Comment stuff
Plug 'tpope/vim-commentary'
" Syntax checking
Plug 'vim-syntastic/syntastic'
call plug#end()
" Basics
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set fileencoding=utf-8
set shiftwidth=4
" Enable autocompletion
set wildmode=longest,list,full
" Comment stuff
autocmd FileType apache setlocal commentstring=#\ %s
autocmd FileType c,cpp,java,lisp setlocal commentstring=//\ %s
" Relative number
set number relativenumber
set nu rnu
" Disable automatic commenting on newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Splits open at the bottom and the right
set splitbelow splitright
" Shortcutting split navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Treat numbers as decimals
set nrformats-=octal
" Theme
set t_Co=256
set background=dark
let g:sonokai_style = 'shusia'
let g:sonokai_enable_italic = 1
let g:sonokai_disable_italic_comment = 1
colorscheme monokai_pro
let g:airline_theme = 'sonokai'
" NERDTree
nmap <F6> :NERDTreeToggle<CR>
" Arrow keys are dead, stupid
noremap <Up> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Down> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Left> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Right> :echo "Arrow keys are dead, stupid!"<CR>
inoremap <Up> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Up> <nop>
inoremap <Down> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Left> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Right> <esc>:echo "Arrow keys are dead, stupid!"<CR>
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap ∆ <Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gv
" Master Vim
let g:hardtime_default_on = 0
" ctrlp
let g:ctrlp_map = '<c-p>'
我电脑的系统版本是macOS Catalina 10.15.7.
如果您希望所有文件的制表符宽度为 4 个空格,vim 实际上您应该使用 3 个设置
:set shiftwidth=4
:set tabstop=4
:retab
使用 "+y
将正常缩进的文本从 Vim 复制到系统剪贴板后,我将其粘贴 VSCode。如图所示,制表符缩进的每一行将缩进两个制表符宽度。
Vim中的代码:
VSCode 中的代码复制自 Vim:
shiftwidth
在我的 .vimrc 中设置为 4,制表符大小在 VSCode.
下面是我的完整 .vimrc:
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'jiangmiao/auto-pairs'
" Theme
Plug 'phanviet/vim-monokai-pro'
Plug 'sainnhe/sonokai'
Plug 'crusoexia/vim-monokai'
Plug 'chriskempson/base16-vim'
" Syntax highlighting
Plug 'sheerun/vim-polyglot'
" Master Vim
Plug 'takac/vim-hardtime'
" Autocomplete
Plug 'ycm-core/YouCompleteMe'
" Full path fuzzy file, buffer, mru, tag, ... finder
Plug 'ctrlpvim/ctrlp.vim'
" Move line
Plug 'matze/vim-move'
" Window
Plug 'tpope/vim-vinegar'
" Status bar
Plug 'vim-airline/vim-airline'
" Git tool
Plug 'tpope/vim-fugitive'
" Comment stuff
Plug 'tpope/vim-commentary'
" Syntax checking
Plug 'vim-syntastic/syntastic'
call plug#end()
" Basics
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set fileencoding=utf-8
set shiftwidth=4
" Enable autocompletion
set wildmode=longest,list,full
" Comment stuff
autocmd FileType apache setlocal commentstring=#\ %s
autocmd FileType c,cpp,java,lisp setlocal commentstring=//\ %s
" Relative number
set number relativenumber
set nu rnu
" Disable automatic commenting on newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Splits open at the bottom and the right
set splitbelow splitright
" Shortcutting split navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Treat numbers as decimals
set nrformats-=octal
" Theme
set t_Co=256
set background=dark
let g:sonokai_style = 'shusia'
let g:sonokai_enable_italic = 1
let g:sonokai_disable_italic_comment = 1
colorscheme monokai_pro
let g:airline_theme = 'sonokai'
" NERDTree
nmap <F6> :NERDTreeToggle<CR>
" Arrow keys are dead, stupid
noremap <Up> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Down> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Left> :echo "Arrow keys are dead, stupid!"<CR>
noremap <Right> :echo "Arrow keys are dead, stupid!"<CR>
inoremap <Up> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Up> <nop>
inoremap <Down> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Left> <esc>:echo "Arrow keys are dead, stupid!"<CR>
inoremap <Right> <esc>:echo "Arrow keys are dead, stupid!"<CR>
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap ∆ <Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gv
" Master Vim
let g:hardtime_default_on = 0
" ctrlp
let g:ctrlp_map = '<c-p>'
我电脑的系统版本是macOS Catalina 10.15.7.
如果您希望所有文件的制表符宽度为 4 个空格,vim 实际上您应该使用 3 个设置
:set shiftwidth=4
:set tabstop=4
:retab