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

This question already has answers here:
error while running "source .vimrc"
(2 answers)
Closed 4 years ago.
I'm trying to configured Vim. However when I try to source .vimrc after having edit the file I get the following error:
$ 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()'
I don't understand where is this error coming from. It throws the error on line call plug#begin() which is closed. Here is the full .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

It looks like you're sourcing your .vimrc from bash. It's not a bash script. Instead, you should source it from inside Vim:
:source ~/.vimrc
:source $MYVIMRC
Or just restart Vim.

It looks like you are trying to source your .vimrc from bash as you would your .bashrc, but this is a vim-specific settings file. vim will naturally source your .vimrc when you run it, if it is in the right place in your path (which it seems to be based on the error message).
If you are already in vim and have made some changes to the .vimrc or wish to load another one, you can source it from within vim by going into command mode and calling source
:source ~/.vimrc

Related

user defined command should be sourced every time at startup - neovim

I'm using Neovim and have the following line in my .init.vim:
command! FZF FloatermNew fzf
It only takes effect if I source $MYVIMRC file every time at startup with :so $MYVIMRC command otherwise it doesn't work.
.init.vim
call plug#begin('~/.config/nvim/plugged')
" Plugins will go here in the middle."
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf.vim'
Plug 'voldikss/vim-floaterm'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'arcticicestudio/nord-vim'
Plug 'scrooloose/nerdtree'
Plug 'itchyny/lightline.vim'
Plug 'fatih/vim-go'
"Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clangd-completer' }
Plug 'Raimondi/delimitMate'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
call plug#end()
source $HOME/.config/nvim/plug-config/floaterm.vim
command! FZF FloatermNew fzf
" now commands are not case-sensitive and write them and hit the tab for
" completion
set ignorecase
"theme
colorscheme nord
set termguicolors
let g:lightline = {'colorscheme': 'deus'}
syntax on
if !exists("g:syntax_on")
syntax enable
endif
" Plugins settings
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
"Golang
let g:go_auto_type_info = 1
let g:go_gocode_unimported_packages = 1
set updatetime=100
let g:go_gopls_complete_unimported = 1
"set completeopt-=preview
"let g:ycm_autoclose_preview_window_after_completion = 1
" ######### Coc Configs #########
" ######### Airline Configs #########
let g:airline_theme='deus'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" ######### FZF Configs #########
"line number
set number
"Auto-save before make command
set autowrite
"Custom key maps
map <F4> :w<CR>:!make<CR>
"without defining run target in Makefile
"map <F4> :w<CR>:!make && make run<CR>
"How can I open a NERDTree automatically when vim starts up?
"autocmd vimenter * NERDTree
"How can I close vim if the only window left open is a NERDTree?
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"focus on right window instead of nerdtree
au VimEnter * wincmd l
map <C-f> :NERDTreeFocus<CR>
"remove tilde for empty lines.
set fcs=eob:\
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
"show a vertical line in the right side of page to indicate a limit for total characters in a line.
"set colorcolumn=110
"highlight ColorColumn ctermbg=darkgray
"Auto-completion
"let g:ycm_global_ycm_extra_conf = '~/Users/admin/.config/nvim/plugged/YouCompleteMe/.ycm_extra_conf.py'
"to improve source code navigation, add something like this to your nvim configuration:
"au FileType c,cpp nnoremap <buffer> <c-]> :YcmCompleter GoTo<CR>
"let g:ycm_server_keep_logfiles = 1
"let g:ycm_server_log_level = 'debug'
Thanks in advance!
There's something called in vim after-directory which is helpful for this situation where you put .vim files and pass the path to :runtimepath command.
I'm using neovim so after-directory in my workflow in a macOS system is like below:
~/.config/nvim/after/plugin/commands.vim
so I command! FZF FloatermNew fzf in that file and then give file path to the :runtimepath so this file will be sourced after all other :scriptnames files sourced.

E492: Not an editor command: NERDTree

When I run vim . to open up a folder I get the following error:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree .
Press ENTER or type command to continue
I don't understand where this is coming from since everything was working fine. I then tried adding other plugins and then the error was thrown. However I have NERDTree in my ~/.vimrc file. Here is what the file looks like.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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 default
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
" Rubocop
let g:vimrubocop_config = '/path/to/rubocop.yml'
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
I re-installed NERDTree but however I still that error.

vim-fireplace cpp don't evaluate every time

I'm having trouble with vim-fireplace using the cpp command.
I'm only using cpp to evaluate the println but at some random point vim enters insert mode and overwrites whatever I type. ESC don't work, only ctrl-c.
This problem is only on my Ubuntu machine, on Mac it works fine.
Here is my vimrc.
filetyp plugin indent on
"set noswapfile
" set filetype detection
filetype on
" VIM-PLUGGED settings ---------------------- {{{
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'vim-scripts/paredit.vim', { 'for': 'clojure' }
" Any valid git URL is allowed
" Plug 'https://github.com/vim-airline/vim-airline.git'
" Initialize plugin system
call plug#end()
" :PlugInstall
" }}}
" GUI set number
set numberwidth=1
set number
" highlight search
set hlsearch incsearch
let mapleader = ","
let maplocalleader = ","
set tabstop=2 " The width of a TAB is set to 4.
set shiftwidth=2
set softtabstop=2
set expandtab
" MAPPINGS
let mapleader = ","
let maplocalleader = ","
inoremap jk <esc>
nnoremap <c-j> 5<c-e>
nnoremap <c-k> 5<c-y>
nnoremap ff :execute "noh"<cr>
" edit vimrc
:nnoremap <leader>ev :vsplit $MYVIMRC<cr>
:nnoremap <leader>sv :source $MYVIMRC<cr>
:nnoremap <leader>ec :split $VIMSETUP/cheetsheet<cr>
:nnoremap <leader>en :split $VIMSETUP/notes<cr>
" Clojure file settings ---------------------- {{{
augroup filetype_clojure
autocmd!
" autocmd FileType clojure nnoremap J gJ
autocmd FileType clojure nmap <leader>e cpp
autocmd FileType clojure nnoremap <leader>r :Require<cr>
augroup END
" }}}
" Vimscript file settings ---------------------- {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
nnoremap <c-b> :NERDTreeToggle<cr>

Buffers not working in vim

My buffers are not working for some reason. When I click <leader>b it says
Not an editor command: Buffers
This is my .vimrc file:
set nocompatible " required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" required
Plugin 'VundleVim/Vundle.vim'
" General
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-commentary'
" User Interface
Plugin 'altercation/vim-colors-solarized'
Plugin 'JarrodCTaylor/vim-256-color-schemes'
Plugin 'JarrodCTaylor/vim-reflection'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'bling/vim-airline'
" Programming
Plugin 'mattn/emmet-vim'
Plugin 'tpope/vim-surround'
Plugin 'leafgarland/typescript-vim'
" Languages
Plugin 'pangloss/vim-javascript'
Plugin 'davidhalter/jedi-vim'
" all plugins must be above this line!!
call vundle#end() " required
filetype plugin indent on " required
" non-plugin stuff after this line!!
" Map leader to ,
let mapleader=','
set t_Co=256
syntax on
set nobackup " Don't constantly write backup files
set noswapfile " Ain't nobody got time for swap files
set noerrorbells " Don't beep
set nowrap " Do not wrap lines
set shiftwidth=4 " Number of spaces to use for each step of indent
set showcmd " Display incomplete commands in the bottom line of the screen
set tabstop=4 " Number of spaces that a <Tab> counts for
set undolevels=1000 " Never can be too careful when it comes to undoing
set hidden " Don't unload the buffer when we switch between them. Saves undo history
set visualbell " Visual bell instead of beeping
set wildmenu " Command-line completion in an enhanced mode
set shell=bash " Required to let zsh know how to run things on the command line
set ttimeoutlen=50 " Fix delay when escaping from insert with Esc
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
set showbreak=↪\
set synmaxcol=256
set scrolloff=3
set clipboard=unnamed
au BufNewFile,BufRead *.json set ft=javascript
" Status line / visual configuration
syntax enable
set t_Co=256
set t_ut=
hi clear
hi String ctermfg=81 ctermbg=NONE cterm=NONE guifg=#5fd7ff guibg=NONE gui=NONE
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
set laststatus=2 " Make the second to last line of vim our status line
let g:airline_theme='understated' " Use the custom theme I wrote
let g:airline_left_sep='' " No separator as they seem to look funky
let g:airline_right_sep='' " No separator as they seem to look funky
let g:airline#extensions#branch#enabled = 0 " Do not show the git branch in the status line
let g:airline#extensions#syntastic#enabled = 1 " Do show syntastic warnings in the status line
let g:airline#extensions#tabline#show_buffers = 0 " Do not list buffers in the status line
let g:airline_section_x = '' " Do not list the filetype or virtualenv in the status line
let g:airline_section_y = '[R%04l,C%04v] [LEN=%L]' " Replace file encoding and file format info with file position
let g:airline_section_z = '' " Do not show the default file position info
let g:airline#extensions#virtualenv#enabled = 0
autocmd BufReadPost quickfix nnoremap <buffer> <CR> :.cc<CR>
autocmd BufReadPost quickfix nnoremap <buffer> o :.cc<CR>
nnoremap <Leader>W :%s/\s\+$//<CR>:let #/=''<CR>
let g:syntastic_check_on_open=1 " check for errors when file is loaded
let g:syntastic_loc_list_height=5 " the height of the error list defaults to 10
let g:syntastic_python_checkers = ['flake8'] " sets flake8 as the default for checking python files
let g:syntastic_javascript_checkers = ['jshint'] " sets jshint as our javascript linter
let g:syntastic_filetype_map = { 'handlebars.html': 'handlebars' }
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html', 'handlebars'] }
set tags=./.ctags,.ctags;
let g:NERDTreeMapJumpNextSibling = ''
let g:NERDTreeMapJumpPrevSibling = ''
let g:gundo_preview_bottom = 1
let g:markdown_fold_style = 'nested'
let g:markdown_fenced_languages = ['python', 'sh', 'vim', 'javascript', 'html', 'css', 'c', 'sql']
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=238
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=249
function! s:DeleteBuffer()
let line = getline('.')
let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+'))
\ : fnamemodify(line[2:], ':p')
exec "bd" bufid
exec "norm \<F5>"
endfunction
" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nmap <F3> :NERDTreeToggle<CR>
" buffer configuration
nnoremap <silent> <leader>b :Buffers<CR>
" close buffer
nnoremap <leader>c :bd<CR>
Can someone tell me if I missed something? I will also accept tips on upgrading my vimrc file so feel free to give any tips :) But I mainly want to fix this problem. So please tell me what I should remove or add to get this working again. It was working before. This really appeared suddenly.
Maybe a typo, see :h buffers
Please change following line (lowercase the B in :Buffers)
nnoremap <silent> <leader>b :Buffers<CR>
to
nnoremap <silent> <leader>b :buffers<CR>

Is there anyway to change VIM Surround's keymapping?

I currently have my .vimrc set up so that
s saves my file
d deletes any text that is highlighted in visual mode
c will comment any line the cursor is on (or any group of highlighted lines)
so obviously this prevents me from using Surround's default commands. Is there a way I can make my own commands in .vimrc to replace Surround's default ones?
Here is my .vimrc
set nocompatible
filetype off " required!
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'jistr/vim-nerdtree-tabs'
" Bundle 'tpope/vim-haml'
Bundle 'ap/vim-css-color'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle "pangloss/vim-javascript"
" vim-scripts repos
Bundle 'surround.vim'
Bundle 'delimitMate.vim'
Bundle 'hail2u/vim-css3-syntax'
" Bundle 'AutoComplPop'
" Bundle 'ervandew/supertab'
Bundle 'snipMate'
Bundle 'tComment'
" Bundle 'mru.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'matchit.zip'
Bundle 'Vimball'
Bundle 'ScrollColors'
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
" Shortcuts
" Basic pair completion
" inoremap { {}<Left>
" inoremap {<CR> {<CR>}<Esc>O
" inoremap {{ {
" inoremap {} {}
" inoremap : :;<Left>
"inoremap :<CR> :;
"noremap :: :;<Left>
"inoremap :; :;
" Create new buffers vertically or horizontally
nnoremap ,v <C-w>v
nnoremap ,h <C-w>s
" Toggle between the buffers
nnoremap ,, <C-w>w
" Increase or decrease buffer size
noremap <C-Up> <C-W>+
noremap <C-Down> <C-W>-
noremap <C-Left> <C-W>>
noremap <C-Right> <C-W><
nmap gf <S-g>
nmap f :FufFile <CR>
vmap c gc
nmap c gcc
nmap tt :tabnew <CR>
nmap tc :tabclose <CR>
nmap ml :MRU <CR>
nmap ,n :NERDTree <CR>;
nmap s :w! <CR>
nmap q :q! <CR>
syntax on
set mouse=a "enables mouse
" map <F2> :NERDTreeToggle<CR>;
map <F2> :NERDTreeTabsToggle<CR>;
" Selecting different color schemes
map <silent> ,3 :NEXTCOLOR<cr>
map <silent> ,2 :PREVCOLOR<cr>
map <silent> ,1 :SCROLL<cr>
" Directory Set up
set backup "backs up files
set backupdir=$HOME/.vimbackup
set directory=$HOME/.vimswap
set viewdir=$HOME/.vimviews
"
" silent execute '!mkdir -p $HOME/.vimbackup'
" silent execute '!mkdir -p $HOME/.vimswap'
" silent execute '!mkdir -p $HOME/.vimviews'
" au BufWinLeave * silent! mkview "makes vim save view state
" au BufWinEnter * silent! loadview "makes vim load view state
" Appearance
set columns=60
set guifont=Monaco\ 11
if has("autocmd")
au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
au VimLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
endif
" set guicursor=n-v-c:block-Cursor
" set guicursor+=i:ver100-iCursor
" set guicursor+=n-v-c:blinkon0
" set guicursor+=i:blinkwait10
if has("gui_running")
set guioptions=aiA " Disable toolbar, menu bar, scroll bars
colorscheme jellybeans
else
colorscheme desert256
endif " has("gui_running")
set t_Co=256
set tabpagemax=10 "show only 10 tabs
set background=dark
set number
set scrolloff=3 "minimum lines to keep above/below cursor
set foldenable "auto fold code
set foldmethod=manual
" Behaviour
" set nowrap "wrap long lines
set linebreak
:filetype plugin indent on " lets filetype plugins be used
" Treat SCSS files as CSS files
" au BufRead,BufNewFile *.scss set filetype=css
" Close VIM even if NERDTree is the last buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" after appending closing delimiter, it indents
let delimitMate_expand_cr=1
" if bufwinnr(1)
" map <kPlus><C-W>+
" map <kMinus><C-W>-
" map <kDivide><c-w><
" map <kMultiply><c-w>>
" endif
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab
set softtabstop=2
set spell
set showmatch "shows matching parens, brackets
set winminheight=0
set go-=T "eliminates tool bar in gVim
set go-=m "eliminates menu bar in gVim
set go-=r "eliminates right scroll bar
set lines=50 "50 lines of text instead of 24
set backspace=2 "makes backspace work like normally it does
:fixdel
set vb t_vb= "prevents vim from beeping when command is bad. instead it flashes screen.
set ruler "shows statusline, displays curor position
set incsearch "vim searches text as you enter it
" set hlsearch "hilights searched items
set ignorecase "case insensitive search
set smartcase "case sensetive when using captials
set wildmenu "shows list instead of completing
set wildmode=list:longest,full "command <TAB> completeiton, lists matches,
set virtualedit=all "lets cursor freely roam anywhere like in command mode
If you take a look at the source for the surround plugin you'll notice the following block:
if !exists("g:surround_no_mappings") || ! g:surround_no_mappings
nmap ds <Plug>Dsurround
nmap cs <Plug>Csurround
nmap ys <Plug>Ysurround
nmap yS <Plug>YSurround
nmap yss <Plug>Yssurround
nmap ySs <Plug>YSsurround
nmap ySS <Plug>YSsurround
xmap S <Plug>VSurround
xmap gS <Plug>VgSurround
if !exists("g:surround_no_insert_mappings") || ! g:surround_no_insert_mappings
if !hasmapto("<Plug>Isurround","i") && "" == mapcheck("<C-S>","i")
imap <C-S> <Plug>Isurround
endif
imap <C-G>s <Plug>Isurround
imap <C-G>S <Plug>ISurround
endif
endif
As you can see, you can prevent the plugin from mapping anything by adding the following to your .vimrc:
let g:surround_no_mappings = 1
Then you can add your own mappings for the functions defined in these blocks.

Resources