gpt4 book ai didi

javascript - Vim 减少 JavaScript 缩进

转载 作者:行者123 更新时间:2023-11-28 07:33:02 25 4
gpt4 key购买 nike

我在 javascript 缩进/减少缩进方面遇到问题。我在网上和 stackoverflow 中进行了搜索。我找到了很多关于缩进的答案,但看起来它们都不是我遇到的相同问题。

当我尝试向对象添加属性时,该属性是数组或对象并且新属性位于另一个对象属性之后,新属性及其括号会缩进为文件的开头。

例如:

Ext.define('FeedReader.view.main.Main', {
extend: 'Ext.container.Container',
requires: [
'FeedReader.view.main.MainController',
'FeedReader.view.main.MainModel'
],
xtype: 'app-main',

// If I add the `items` found below up here, the indenting is fine

controller: 'main',
viewModel: {
type: 'main'
},
layout: {
type: 'border'
},

// If I add the `items` property here, the following outdenting occurs
items:[

]

...the rest of the object

当我在新创建的属性的括号之间创建换行符时,就会发生缩进。

有人遇到过这个问题吗?

编辑

这是我的 .vimrc 如果有帮助的话。抱歉,有点草率!

call pathogen#infect()
syntax on
filetype plugin on

set t_Co=256

set encoding=utf-8
" Prevents the hiding of double quotes in json formatted files.
set conceallevel=0

hi clear SpellBad
hi SpellBad cterm=underline,bold ctermfg=white ctermbg=red

set relativenumber
set number

set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
set smartindent
set nowrap
set hlsearch
set backspace=indent,eol,start "Allow backspace to work like most other apps, e.g. deleting a line ending will take you to the previous line

set backupdir=~/vim_backups
set swapfile
set dir=~/vim_swaps
set showmode
set mouse=nicr
set laststatus=2

" Setting character to use for showing indents in indentLine bundle
let g:indentLine_char = '|'
let g:indentLine_color_term = 236


" NerdTree specific configs
let NERDTreeShowHidden=1


" Setting the path so we can use the :find command
set path=$PWD/**

" Function Key Mappings ===============================================

"F2

" Toggle spell check
:map <F2> :setlocal spell! spelllang=en_us<CR>

" Toggle spell check in insert mode
":imap <F2> <Esc>:setlocal spell! spelllang=en_us<CR>i
inoremap <F2> <C-\><C-O>:setlocal spelllang=en_us spell! spell?<CR>

"F3

" Underline the current line with dashes in normal mode
nnoremap <F3> yyp<c-v>$r-

" Underline the current line with dashes in insert mode
inoremap <F3> <Esc>yyp<c-v>$r-A

"F4

" Double Underline the current line with dashes in normal mode
nnoremap <F4> yyp<c-v>$r=

" Double Underline the current line with dashes in insert mode
inoremap <F4> <Esc>yyp<c-v>$r=A

" Control Key Mappings ===============================================

" CTRL-h

" ctrl+c to toggle highlight.
let hlstate=0
nnoremap <c-h> :if (hlstate%2 == 0) \| nohlsearch \| else \| set hlsearch \| endif \| let hlstate=hlstate+1<cr>

" CTRL-n

" Toggle NerdTree
map <C-n> :NERDTreeToggle<CR>

" CTRL-l

" Toggle NerdTree
map <C-l> :! clear ; php -l %<CR>

" Smooth the scrolling for ctrl-e, ctrl-y, and mouse wheel
map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y> |
map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>

" Moving entire lines up and down
map <C-UP> ddkP
map <C-DOWN> ddp

inoremap <C-UP> <ESC>ddkPi
inoremap <C-DOWN> <ESC>ddpi

" Insert empty lines without going into insert mode
" Enter = line below, Shift Enter = line above
nmap <S-Return> O<Esc>
nmap <CR> o<Esc>

"Start tabular command
vmap <S-t> :Tab /

"Control P buffer only
noremap <C-b> :CtrlPBuffer<CR>

" Highlight all instances of pattern on double click:
:map <2-LeftMouse> *


"Enable powerline symbols for airline
let g:airline_powerline_fonts = 1

" suppress syntax errors for html when working with ember.
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html'] }

另外,当获取我的 vimrc 时,我记得我确实安装了 pathegon,所以这是我正在使用的 bundle 列表(从我的 ~/.vim/bundles/目录中提取):

  • Vundle.vim
  • 确认
  • 命令-t
  • ctrlp.vim
  • 缩进
  • Nerd 树
  • 综合
  • 表格
  • vim-航空公司
  • vim-colors-solarized
  • vim-javascript
  • vim 环绕

最佳答案

我在我的 vim 终端中执行了你的代码,没有遇到这个问题。您能否检查一下 .vimrc 的要点,看看其中是否有任何内容可能导致此问题?

我不确定 indentLine 但看看添加它是否有助于格式选项:

set formatoptions=crnqn1j

我仍在学习所有格式化选项,但如果这对您有帮助,这可能是一个好的开始。我还将查看 indentLine 插件,看看是否能找到任何东西。

关于javascript - Vim 减少 JavaScript 缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28906854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com