vim - .vimrc : line 4: syntax error near unexpected token `('

标签 vim

这个问题在这里已经有了答案:





error while running "source .vimrc"

(2 个回答)


3年前关闭。




我正在尝试配置 Vim。但是,当我尝试获取 .vimrc 时编辑文件后,我收到以下错误:

$ source ~/.vimrc -bash: let g:plug_shallow = 0 : command not found -bash: /Users/stevenaguilar/.vimrc: line 4: syntax error near unexpected token (' -bash: /Users/stevenaguilar/.vimrc: line 4:call plug#begin()'



我不明白这个错误来自哪里。它在行 call plug#begin() 上抛出错误这是关闭的。这是完整的.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:plug_shallow = 0 " disable shallow cloning

call plug#begin()

Plug 'airblade/vim-gitgutter'                 " shows a git diff in the gutter
Plug 'altercation/vim-colors-solarized'       " precision colorscheme
Plug 'godlygeek/tabular'                      " text filtering and alignment
Plug 'janko-m/vim-test'                       " test runner
Plug 'phallstrom/vim-sailfish'
Plug 'scrooloose/nerdtree'                    " tree explorer
Plug 'sjl/gundo.vim'                          " graph your vim undo tree
Plug 'tpope/vim-commentary'                   " comment stuff out
Plug 'tpope/vim-endwise'                      " wisely add 'end' in ruby, endfunction/endif/more in vim script, etc
Plug 'tpope/vim-fugitive'                     " git wrapper
Plug 'tpope/vim-rails', { 'for': ['ruby'] }   " ruby on rails power tools
Plug 'vim-ruby/vim-ruby', { 'for': ['ruby'] } " vim/ruby configuration
Plug 'tpope/vim-projectionist'                " project configuration (file jumping)
Plug 'kana/vim-textobj-user'                  " create your own text objects
Plug 'nelstrom/vim-textobj-rubyblock'         " custom text object for selecting ruby blocks
Plug 'tpope/vim-surround'                     " quoting/parenthesizing made simple
Plug 'chriskempson/base16-vim'                " color schemes, https://chriskempson.github.io/base16/
Plug 'w0rp/ale'                               " asynchronous lint engine
Plug 'editorconfig/editorconfig-vim'          " editorConfig plugin
Plug 'vim-airline/vim-airline'                " status/tabline
Plug 'vim-airline/vim-airline-themes'         " status/tabline themes
Plug 'pangloss/vim-javascript'                " Javascript syntax
Plug 'mxw/vim-jsx'                            " react jsx syntax
Plug 'posva/vim-vue', { 'for': ['vue'] }      " Vue.js syntax
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' " A command-line fuzzy finder written in Go
Plug 'kien/rainbow_parentheses.vim', { 'for': ['clojure'] } " Better Rainbow Parentheses
Plug 'guns/vim-clojure-static', { 'for': ['clojure'] } " Meikel Brandmeyer's excellent Clojure runtime files
Plug 'tpope/vim-unimpaired'                   " pairs of handy bracket mappings
Plug 'tpope/vim-abolish'                      " easily search for, substitute, and abbreviate multiple variants of a word
Plug 'mechatroner/rainbow_csv'                " highlighting columns in csv/tsv files
Plug 'slim-template/vim-slim' " slim syntax highlighting for vim

call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

set t_Co=256

set nocompatible      " We're running Vim, not Vi!
set synmaxcol=500     " don't try to highlight long lines
compiler ruby         " Enable compiler support for ruby

filetype plugin on

set background=dark
colorscheme base16-oceanicnext

set backspace=2
set expandtab
set tabstop=2 shiftwidth=2 softtabstop=2
set autoindent
set nowrap
set nrformats=

set backupdir=$HOME/.vimbackup,.
set directory=$HOME/.vimswap,.

au FocusLost * :wa

set ignorecase
set smartcase
set scrolloff=2
set ttyfast
set hidden
set wildmenu
set wildmode=list:longest
nnoremap <leader>nt :NERDTreeToggle<enter>

source $VIMRUNTIME/macros/matchit.vim

" fzf
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>b :Buffers<CR>

" https://github.com/tpope/vim-commentary/commit/4dcfc318e0b02fdbb0c2d9ff77cf3562b46eea25
xmap \\  <Plug>Commentary
nmap \\  <Plug>Commentary

set updatetime=250

nmap <silent> <leader>s :TestNearest<CR>
nmap <silent> <leader>t :TestFile<CR>
nmap <silent> <leader>T :TestSuite<CR>

set mouse=a
vnoremap <Leader>c "*y
noremap <Leader>v "*p

set nofixeol

set formatoptions+=j " Delete comment character when joining commented lines

au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
    \ exe "normal g'\"" | endif

let g:omni_sql_no_default_maps = 1 " disable SQL autocompletion entirely

" To ensure that EditorConfig plugin works well with Tim Pope's fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']

" ALE - Asynchronous Lint Engine
let g:ale_lint_on_enter = 0        " no checks on open
let g:ale_lint_on_save = 1         " check on save
let g:ale_lint_on_text_changed = 1 " check on text change
let g:ale_lint_delay = 300         " millisecond delay before checking

" Airline
let g:airline_theme = 'base16'                  " theme
set laststatus=2                                " always show airline
set noshowmode                                  " hide default mode indicator
let g:airline_powerline_fonts = 1               " use powerline font
let g:airline#extensions#wordcount#enabled = 0  " disable word counting
let g:airline#extensions#whitespace#enabled = 0 " disable detection of whitespace errors

if filereadable($HOME."/.vimrc_local")
  source $HOME/.vimrc_local
endif

let g:jsx_ext_required = 0 " JSX syntax in .js files

" open file splits in vsplit by default
:nnoremap <C-W>f :vertical wincmd f<CR>

" https://github.com/posva/vim-vue#how-can-i-use-existing-configurationplugins-in-vue-files
" autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css

au FileType clojure exe "RainbowParenthesesLoadRound" | RainbowParenthesesActivate

" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif

" https://github.com/slim-template/vim-slim/issues/38#issuecomment-23760100
autocmd BufNewFile,BufRead *.slim setlocal filetype=slim

最佳答案

看起来您是从 bash 采购 .vimrc 的。它不是 bash 脚本。相反,您应该从 Vim 内部获取它:

:source ~/.vimrc
:source $MYVIMRC

或者只是重新启动 Vim。

关于vim - .vimrc : line 4: syntax error near unexpected token `(' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52413694/

相关文章:

svn 差异| view - 如何突出显示基于字符的更改而不是仅基于行的更改?

macos - OS X 终端 UTF-8 问题

vim - Vim 脚本有办法在任何错误时停止吗?

vim - GoImports 取消 html 语法高亮

syntax-highlighting - 持久:set syntax for a given filetype?

vim - 当我在命令行中输入时如何让 Vim 使用绝对行号,否则如何使用相对行号?

intellij-idea - 如何在ideavim中进行不区分大小写的搜索(使用/和?)

ruby-on-rails - rails.vim 支持 .less css 文件的语法高亮吗?

c++ - 如何使构建/编译更舒适

regex - 如何使用vim/grep否定 future