syntax error: unexpected end of file and etc. problems in .vimrc - linux

In my limited experience with shell, I didn't know how to solve this error.
Thanks in advance.
Here are exceptions:
[user#pc-name ~]$ source .vimrc
-bash: Configuration file for vim
set modelines=0 : command not found
-bash: Normally we use vim-extensions. If you want true vi-
compatibility
: command not found
-bash: .vimrc: line 45: unexpected EOF while looking for matching `"'
-bash: .vimrc: line 48: syntax error: unexpected end of file
Here is my .vimrc:
[user#pc-name ~]$ cat .vimrc
" Configuration file for vim
set modelines=0 " CVE-2007-2438
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi
compatibility
set backspace=2 " more powerful backspacing
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup nobackup
syntax enable
set background=dark
colorscheme solarized
filetype on " 检测文件的类型
set number " 显示行号
set cursorline " 用浅色高亮当前行
"autocmd InsertLeave * se nocul
"autocmd InsertEnter * se cul
set tabstop=4 " Tab键的宽度
set softtabstop=4
set shiftwidth=4 " 统一缩进为4
set autoindent " vim使用自动对齐,也就是把当前行的对齐格式应用到下一行(自动缩进)
set cindent " (cindent是特别针对 C语言语法自动缩进)
set smartindent " 依据上面的对齐格式,智能的选择对齐方式,对于类似C语言编写上有用
set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
set incsearch " 输入搜索内容时就显示搜索结果
set hlsearch " 搜索时高亮显示被找到的文本
set foldmethod=indent " 设置缩进折叠
set foldlevel=99 " 设置折叠层数
nnoremap <space> #=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" 用空格键来开关折叠
" 自动跳转到上次退出的位置
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

The error occurs because .vimrc files are read by the vim texteditor, not your bash shell. It makes no sense to source .vimrc, because the file is not understood (nor intended to be) by bash.

Related

neovim adds ^M at the end of the after saving

I'm new to using neovim so pardon me if the fix is too obvious.
The issue that I'm having is that if I create a file using the command.
nvim file.txt
and then edit it let's say something like this
hello
then save it with :w
the file will show as the following
hello^M
I tried the command :set ff=unix
but I does not work. I think the issue is the init.vim which I took from https://github.com/craftzdog/dotfiles-public
and modify it to not use fish as a terminal, the code is the following.
" Fundamentals "{{{
" ---------------------------------------------------------------------
" init autocmd
autocmd!
" set script encoding
scriptencoding utf-8
" stop loading config if it's on tiny or small
if !1 | finish | endif
set nocompatible
set number
syntax enable
set fileencodings=utf-8,sjis,euc-jp,latin
set encoding=utf-8
set title
set autoindent
set background=dark
set nobackup
set hlsearch
set showcmd
set cmdheight=1
set laststatus=2
set scrolloff=10
set expandtab
"let loaded_matchparen = 1
set shell=powershell.exe
set backupskip=/tmp/*,/private/tmp/*
" incremental substitution (neovim)
if has('nvim')
set inccommand=split
endif
" Suppress appending <PasteStart> and <PasteEnd> when pasting
set t_BE=
set nosc noru nosm
" Don't redraw while executing macros (good performance config)
set lazyredraw
"set showmatch
" How many tenths of a second to blink when matching brackets
"set mat=2
" Ignore case when searching
set ignorecase
" Be smart when using tabs ;)
set smarttab
" indents
filetype plugin indent on
set shiftwidth=2
set tabstop=2
set ai "Auto indent
set si "Smart indent
set nowrap "No Wrap lines
set backspace=start,eol,indent
" Finding files - Search down into subfolders
set path+=**
set wildignore+=*/node_modules/*
" Turn off paste mode when leaving insert
autocmd InsertLeave * set nopaste
" Add asterisks in block comments
set formatoptions+=r
"}}}
" Highlights "{{{
" ---------------------------------------------------------------------
set cursorline
"set cursorcolumn
" Set cursor line color on visual mode
highlight Visual cterm=NONE ctermbg=236 ctermfg=NONE guibg=Grey40
highlight LineNr cterm=none ctermfg=240 guifg=#2b506e guibg=#000000
augroup BgHighlight
autocmd!
autocmd WinEnter * set cul
autocmd WinLeave * set nocul
augroup END
if &term =~ "screen"
autocmd BufEnter * if bufname("") !~ "^?[A-Za-z0-9?]*://" | silent! exe '!echo -n "\ek[`hostname`:`basename $PWD`/`basename %`]\e\\"' | endif
autocmd VimLeave * silent! exe '!echo -n "\ek[`hostname`:`basename $PWD`]\e\\"'
endif
"}}}
" File types "{{{
" ---------------------------------------------------------------------
" JavaScript
au BufNewFile,BufRead *.es6 setf javascript
" TypeScript
au BufNewFile,BufRead *.tsx setf typescriptreact
" Markdown
au BufNewFile,BufRead *.md set filetype=markdown
au BufNewFile,BufRead *.mdx set filetype=markdown
" Flow
au BufNewFile,BufRead *.flow set filetype=javascript
" powershell
au BufNewFile,BufRead *.pwsh set filetype=powershell
set suffixesadd=.js,.es,.jsx,.json,.css,.less,.sass,.styl,.php,.py,.md
autocmd FileType coffee setlocal shiftwidth=2 tabstop=2
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2
"}}}
" Imports "{{{
" ---------------------------------------------------------------------
runtime ./plug.vim
if has("unix")
let s:uname = system("uname -s")
" Do Mac stuff
if s:uname == "Darwin\n"
runtime ./macos.vim
endif
endif
if has('win32')
runtime ./windows.vim
endif
runtime ./maps.vim
"}}}
" Syntax theme "{{{
" ---------------------------------------------------------------------
" true color
if exists("&termguicolors") && exists("&winblend")
syntax enable
set termguicolors
set winblend=0
set wildoptions=pum
set pumblend=5
set background=dark
" Use NeoSolarized
let g:neosolarized_termtrans=1
runtime ./colors/NeoSolarized.vim
colorscheme NeoSolarized
endif
"}}}
" Extras "{{{
" ---------------------------------------------------------------------
set exrc
"}}}
" vim: set foldmethod=marker foldlevel=0:
any help would be so much appreciated
Quick note It appears that the issue only happens when is a .tsx file
I finally found the culprit. It was prettier, I remove it from the lspconfig.rc file as a temporary solution please let me know if you why this was happening

disable replace mode when i launch vim

When I run vim it puts me in --REPLACE-- mode, how I put it in command mode or insertion mode.
( And how to activate these commands by default when I run vim?
- :set nu
- :set cc=80
)
vimrc
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
filetype plugin on
if &term=="xterm"
set t_Co=8
set t_Sb=[4%dm
set t_Sf=[3%dm
endif
" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 21 2016 17:00:20)
Included patches: 1-160

Vim "preview" tab pops-up when selecting a suggestion from autocomplete [duplicate]

This question already has answers here:
How can I disable scratch preview window?
(2 answers)
Closed 5 years ago.
How do I get rid of the preview tab at the top that is popping up when I select an autocomplete suggestion?
here is my .vimrc mostly copied from someone else(julienschmidt) as I'm new to vim but I see nothing about tags.
" -----------------
" General
" -----------------
set nocp "enable Vi incompatible features
filetype plugin on "per-filetype settings
set shiftwidth=2
set tabstop=2
" -----------------
" Plugins
" -----------------
execute pathogen#infect()
" ----------------
" Encoding
" ----------------
set encoding=utf-8 "utf-8 encoding
set termencoding=utf-8 "utf-8 terminal
scriptencoding utf-8
set ff=unix "unix line endings
" -----------------
" Theme
" -----------------
set t_Co=256
syntax on "syntax highlighting
set nu "show line numbers
set ru "show ruler at cursor pos
set cursorline "highlight current line
set hlsearch "highlight search results
set showmatch "matching parentheses
set gcr=n:blinkon0 "turn off blinking cursor in normal mode
" highlight the word under cursor (CursorMoved is inperformant)
highlight WordUnderCursor cterm=underline "ctermfg=7
autocmd CursorHold * exe printf('match WordUnderCursor /\V\<%s\>/', escape(expand('<cword>'), '/\'))
"statusbar
set laststatus=2
" ----------------
" Behavior
" ----------------
set ai "autoindent
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set shiftround "round > < to shiftwidth
set ignorecase smartcase "ignore case, except if contains uppercase
set noerrorbells visualbell t_vb= "don't ring the bell
set incsearch "incremental search
set mouse=a "enable mouse
set mousehide "Hide the mouse cursor while typing
set virtualedit=onemore "Allow for cursor beyond last character
set sc "show incomplete commmands
set tw=72 "textwidth 72 characters
autocmd GUIEnter * set visualbell t_vb=
if has('clipboard')
if has('unnamedplus') "use + register for copy-paste when available
set clipboard=unnamed,unnamedplus
else "otherwise try to use * register
set clipboard=unnamed
endif
endif
"go
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <leader>co <Plug>(go-coverage)
"Markdown
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh']
"always start in first line in git commit messages
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
"refresh vimrc after saving
autocmd BufWritePost ~/.vimrc source %
autocmd BufWritePost ~/.vim/vimrc source %
The add-ons in my bundle are auto-pairs, nerdtree, vim-airline, vim-fugitive, vim-go, YouCompleteMe. I'm guessing airline or YCM are the issue? Anyway if there's a something I can put in my .vimrc to disable this I would greatly appreciate it.
I actually found the answer myself using trusty google: https://github.com/Valloric/YouCompleteMe/issues/2015. It's a "feature" of YouCompleteMe and can be turned off by placing set completeopt-=preview in the .vimrc. I'll leave this for google searches.

how to install VIM + Vuddle on msys2

Vim came as default on my msys2 version but I don't see the ~/.vimrc file nor ~/.vim/ directory
any thoughts
just place a file in /etc/vimrc
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif

Vim: inoremap works in buffer, not in .vimrc

I'm really eager to include the following in my .vimrc file:
inoremap <Tab> <C-x><C-u>
If I set it within a buffer (via :inoremap <Tab> <C-x><C-u>) it works exactly as I'd hoped.
But, if I place it in my .vimrc, it doesn't seem to be acknowledged at all.
I've attached my .vimrc below. A few things:
Other changes to the .vimrc file are picked up, so it's not the wrong file
Have tried adding at the very bottom of the .vimrc & still doesn't work, so it's not being overwritten
Any ideas appreciated. Many thanks.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Word complete
" :autocmd BufEnter * call DoWordComplete()
" let g:WC_min_len = 4
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
map j gj
map k gk
set showmatch " Show matching brackets
set mat=5 " Bracket blinking
set noerrorbells " No noise
" Ruby autocomplete
" Autocomplete behaviour
set completeopt=longest,menuone
open omni completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
" open user completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" highlight Pmenu ctermbg=238 gui=bold "improve autocomplete menu color
" Colours
highlight Pmenu ctermfg=6 ctermbg=238 guibg=grey30
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" if has("vms")
" set nobackup " do not keep a backup file, use versions instead
" else
" set backup " keep a backup file
" endif
" Set backupdir to tmp
" Do not let vim create <filename>~ backup files
set nobackup
" set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Set tab to 2 spaces
set ts=2
set shiftwidth=2
" Ignore case
set ignorecase
set smartcase
" Menu autocomplete
set wildmode=longest,list
set wildmenu
" Call pathogen
call pathogen#infect()
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Turn syntax highlighting on (Added by John Bayne, 18/08/2012)
syntax on
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" My customisations
" No backup files
set nobackup
set nowritebackup
set noswapfile
" Whitespace identifier
:highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
:match ExtraWhitespace /\s\+$/
" Colour options
" color codeschool
" set guifont=Monaco:h12
" let g:NERDTreeWinPos = "right"
" set guioptions-=T " Removes top toolbar
" set guioptions-=r " Removes right hand scroll bar
" set go-=L " Removes left hand scroll bar
" autocmd User Rails let b:surround_{char2nr('-')} = "<% \r %>" " displays <% %> correctly
" :set cpoptions+=$ " puts a $ marker for the end of words/lines in cw/c$ commands
" Tab behaviour for ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
inoremap <Tab> <C-x><C-u>
In this case, :scriptnames, while useful, is not the best way to see where a mapping was last set.
:verbose map <tab>
is a lot more precise.
Maybe another script is overwriting it after your .vimrc is read.
You can use :scriptnames to see what files are read on startup.

Resources