I can not fold my code in macvim
my environment and settings is at the gist link https://gist.github.com/poc7667/7035979
is there any idead ?
hi Comment ctermfg=6
"function SetCafeOptions()
"CoffeeCompile
":set nonu
":res -24
":res +24
"endfunction
set encoding=utf-8
set fileencoding=utf-8
colorscheme elflord
set smartindent
set tabstop=4
set expandtab
set shiftwidth=4
"make it autoreload
set autoread
"auto move it last time the position you viewed
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."
"try to set show ansi color
if &term=="ansi"
set t_Co=0
endif
"set expandtab
filetype on
if has("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 cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif
"let Tlist can close windows at one time
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
" Key map
" Presee F4 and you can open the NERDTree
nnoremap <silent> <F4> :NERDTree<CR>
"nnoremap <silent> <F3> :!/usr/bin/env python %<CR>
" Show function List with Tlist
nnoremap <F12> :TlistToggle<CR>
" Map ctrl+q to ctrlw+ctrlw
"
"nnoremap <silent> <C-q> :<C-w><C-w>
"switch in splitted window
map <c-d> <c-w>l
map <c-a> <c-w>h
"set highlight
set hlsearch
"set autocomplet
"autocmd BufNewFile,BufRead *.html.erb set filetype=html.eruby
autocmd BufNewFile,BufRead *.html.erb set filetype=erb.html.eruby
filetype plugin on
"auto import python template
autocmd bufnewfile *.py 0r ~/common_lib/python/tmpl.py
map gn :bn<cr>
map gp :bp<cr>
map ff :CtrlP<cr>
map gt :buffers<cr>
"set NerdTreeSize
let g:NERDTreeWinSize=12
"auto close the nerdtress window whe you open new file
let g:ctrlp_dont_split = 'nerdtree'
set nocompatible " explictly get out of vi-compatible mode
set background=dark " we plan to use a dark background
syntax on " syntax highlighting on
set number " turn on line numbers
set wildignore+=*/test/*,*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set ruler "always show current position along the bottom
set incsearch " do highlight as you type you search phrase
set ignorecase " case insensitive by default
set smartcase " if there are caps, go case-sensitive
"Rope vim
let $PYTHONPATH .= ":~/install/ropehg/rope:~/install/ropehg/ropemode:~/install/ropehg/ropevim"
source ~/install/ropehg/ropevim/ropevim.vim
let g:pymode_rope_goto_def_newwin = "new"
let ropevim_vim_completion=1
"Use Ctrl + ] . to autocomple
inoremap <C-]> <C-R>=RopeCodeAssistInsertMode()<CR>
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>
" Load the whole plugin
let g:pymode = 1
" Load run code plugin
let g:pymode_run = 1
"add ctrlp.vim setting
""
let g:ctrlp_custom_ignore = 'tmp$\|\.git$\|\.hg$\|\.svn$\|.rvm$'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=15
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
"Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-surround'
Bundle 'Raimondi/delimitMate'
"coffee script"
Bundle 'kchmck/vim-coffee-script'
Bundle 'ack.vim'
Bundle 'matchit.zip'
"Markdown"
"Bundle 'plasticboy/vim-markdown'
""Vim-scripts repo
Bundle 'The-NERD-Commenter'
Bundle 'pep8'
""Bundle 'AutoClose'
filetype plugin indent on
nmap <leader>a <Esc>:Ack ""
"folding code
nnoremap <space> za
vnoremap <space> zf
" pep8
let g:pep8_map='<leader>8'
"coffee script"
call pathogen#infect()
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."
au BufWinLeave *.* mkview
au BufWinEnter *.* silent loadview
let Tlist_Use_Right_Window = 1
"autocmd BufEnter * if &filetype == "" | setlocal ft=python | endif
"markdown https://github.com/plasticboy/vim-markdown/wiki"
"let g:vim_markdown_folding_disabled=1
"auto exec ruby and coffee script with F5 , remeber to save file before launching
autocmd FileType python map <leader>p :!python %<cr>
autocmd FileType ruby,rb map <leader>5 :w!<cr>:!ruby %<cr>
autocmd FileType * map <leader>e :qa!<cr>
"autocmd FileType coffee nmap <F5> :CoffeeCompile<cr>
"autocmd FileType coffee map <F5> :call SetCafeOptions()<cr>
so ~/.vim/snippets/support_functions.vim
Your .vimrc doesn't actually enable folding anywhere. Folding is not enabled by default. You need to tell Vim what method to use to fold your code.
What method you use might depend on what type of code you are editing. SOME syntax highlighting files define syntax-based folding. Other syntax files do not. If your code is of a type that supports syntax-based folding, then you can :setlocal foldmethod=syntax after loading the file. You can do this in an autocmd in your .vimrc if you like, for example autocmd FileType c setlocal foldmethod=syntax or you can do it manually.
Other automatic fold methods include "marker", "expr", and "indent". By default the fold method is "manual" and you must first create folds with zf in order to use folding commands.
See http://vim.wikia.com/wiki/Folding for a more detailed discussion.
Removing these lines solve the folding problem for me:
au BufWinLeave *.* mkview
au BufWinEnter *.* silent loadview
Related
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>
So I am using the omnisharp-vim plugin along with syntastic to show my errors in my web project. When I load a cs file up it is reporting all these errors. When I open the same project up in VS 2015 I do not see the same errors
MyProject.Web\Controllers\DashboardController.cs|11 col 52 error| 'MyProjectAuthorizeAttribute' is not a known identifier
MyProject.Web\Controllers\DashboardController.cs|11 col 54 error| Error: ?
MyProject.Web\Controllers\DashboardController.cs|12 col 51 error| 'BaseController' is not a known identifier
MyProject.Web\Controllers\DashboardController.cs|14 col 27 error| 'ILogger' is not a known identifier
MyProject.Web\Controllers\DashboardController.cs|15 col 44 error| 'ILoggerFactory' is not a known identifier
Maybe I am missing some configuration in my .vimrc file?
" General -----------------------
set nocompatible " Makes vim better
scriptencoding utf-8 " Setting everything to UTF-8
set encoding=utf-8
set history=256
set timeoutlen=250
set clipboard+=unnamed
let g:autotagTagsFile = ".git/tags"
set tags=./.git/tags,tags,./.git/coffeetags,coffeetags;$HOME
set nobackup
set nowritebackup
set noswapfile
set hlsearch
set ignorecase
set smartcase
set incsearch
" turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
let mapleader = ','
let maplocalleader = ' '
let g:netrw_banner = 0
" Formatting --------------------
set nowrap
set tabstop=4
set softtabstop=4
set shiftwidth=4
set backspace=indent
set backspace+=eol
set backspace+=start
set autoindent
set cindent
set indentkeys-=0#
set cinkeys-=0#
set cinoptions=:s,ps,ts,cs
set cinwords=if,else,while,do
set cinwords+=for,switch,case
set linespace=4
set listchars=tab:>.,trail:.,extends:\#,nbsp:.
set list
" Plugins ------------------------
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'OmniSharp/omnisharp-vim'
Plugin 'tpope/vim-dispatch'
Plugin 'scrooloose/syntastic'
Plugin 'Shougo/unite.vim'
Plugin 'xero/sourcerer.vim'
Plugin 'bling/vim-airline'
Plugin 'airblade/vim-gitgutter'
Plugin 'ap/vim-css-color'
Plugin 'groenewege/vim-less'
Plugin 'hail2u/vim-css3-syntax'
Plugin 'kien/ctrlp.vim'
Plugin 'jasoncodes/ctrlp-modified.vim'
Plugin 'kaneshin/ctrlp-git-log'
Plugin 'jiangmiao/auto-pairs'
Plugin 'lokaltog/vim-easymotion'
Plugin 'majutsushi/tagbar'
Plugin 'mattn/ctrlp-git'
Plugin 'tacahiroy/ctrlp-funky'
Plugin 'mattn/emmet-vim'
Plugin 'mtscout6/rainbow_parentheses.vim'
Plugin 'mtscout6/vim-ctags-autotag'
Plugin 'mtscout6/vim-tagbar-css'
Plugin 'scrooloose/nerdtree'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-git'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-surround'
call vundle#end()
filetype plugin indent on
" Rainbow
map <leader>rt :RainbowParenthesesToggle<CR>
map <leader>r( :RainbowParenthesesLoadRound<CR>
map <leader>r[ :RainbowParenthesesLoadSquare<CR>
map <leader>r{ :RainbowParenthesesLoadBraces<CR>
map <leader>r< :RainbowParenthesesLoadChevrons<CR>
" File Type Settings --------------------
" Markdown editing
autocmd Filetype markdown setlocal wrap
autocmd Filetype markdown setlocal linebreak
autocmd Filetype markdown setlocal nolist
autocmd Filetype markdown setlocal columns=80
autocmd Filetype markdown setlocal tw=80
autocmd Filetype markdown setlocal wm=4
" GVIM Options -----------------------
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=L
" Visual ------------------------
syntax on
set showmatch
if has('gui_running')
set guifont=InputMono:h14
colorscheme sourcerer
if has('mac')
set noantialias
endif
endif
set novisualbell
set noerrorbells
set vb t_vb=
set laststatus=2
" Airline Settings
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" Default
let g:airline#extensions#tmuxline#enabled = 0
" Presentation
"let g:airline#extensions#tmuxline#enabled = 1
" Ctrl-P settings
let g:ctrlp_working_path_mode = 'r'
let g:ctrlp_extensions = ['tag', 'buffertag', 'line', 'funky']
", 'git-log', 'git_branch', 'git_files', 'modified']
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git|bower_components'
map <leader>t :CtrlP<CR>
map <leader>gs :CtrlPGitFiles<CR>
map <leader>gb :CtrlPGitBranch<CR>
map <leader>gl :CtrlPGitLog<CR>
map <leader>gm :CtrlPModified<CR>
" ctrlp-modified
map <Leader>m :CtrlPModified<CR>
map <Leader>M :CtrlPBranch<CR>
" Tagbar settings
map <F8> :TagbarToggle<CR>
" Emmet settings
imap <C-e> <C-y>,
" Multiple Cursor Settings
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_start_key='<leader>m'
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" Git Gutter Settings
highlight clear SignColumn
map ]h <Plug>GitGutterNextHunk
map [h <Plug>GitGutterPrevHunk
map <leader>hv <Plug>GitGutterPreviewHunk
map <Leader>hs <Plug>GitGutterStageHunk
map <Leader>hr <Plug>GitGutterRevertHunk
" NERD Tree Settings
map <TAB> :NERDTreeToggle<CR>
map <leader>ff :NERDTreeFind<CR>
let NERDTreeShowHidden=1
let NERDTreeIgnore=[]
" Syntastic Settings
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"let g:syntastic_<filetype>_checkers = ['omnisharp']
let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues']
" Omnisharp settings
let g:OmniSharp_server_type = 'roslyn'
let g:OmniSharp_selector_ui = 'unite'
let g:OmniSharp_selector_ui = 'ctrlp'
let g:OmniSharp_timeout = 1
set noshowmatch
set completeopt=longest,menuone,preview
set splitbelow
augroup omnisharp_commands
autocmd!
"Set autocomplete function to OmniSharp (if not using YouCompleteMe completion plugin)
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
" Synchronous build (blocks Vim)
"autocmd FileType cs nnoremap <F5> :wa!<cr>:OmniSharpBuild<cr>
" Builds can also run asynchronously with vim-dispatch installed
autocmd FileType cs nnoremap <leader>b :wa!<cr>:OmniSharpBuildAsync<cr>
" automatic syntax check on events (TextChanged requires Vim 7.4)
autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
" Automatically add new cs files to the nearest project on save
autocmd BufWritePost *.cs call OmniSharp#AddToProject()
"show type information automatically when the cursor stops moving
autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
"The following commands are contextual, based on the current cursor position.
autocmd FileType cs nnoremap gd :OmniSharpGotoDefinition<cr>
autocmd FileType cs nnoremap <leader>fi :OmniSharpFindImplementations<cr>
autocmd FileType cs nnoremap <leader>ft :OmniSharpFindType<cr>
autocmd FileType cs nnoremap <leader>fs :OmniSharpFindSymbol<cr>
autocmd FileType cs nnoremap <leader>fu :OmniSharpFindUsages<cr>
"finds members in the current buffer
autocmd FileType cs nnoremap <leader>fm :OmniSharpFindMembers<cr>
" cursor can be anywhere on the line containing an issue
autocmd FileType cs nnoremap <leader>x :OmniSharpFixIssue<cr>
autocmd FileType cs nnoremap <leader>fx :OmniSharpFixUsings<cr>
autocmd FileType cs nnoremap <leader>tt :OmniSharpTypeLookup<cr>
autocmd FileType cs nnoremap <leader>dc :OmniSharpDocumentation<cr>
"navigate up by method/property/field
autocmd FileType cs nnoremap <C-K> :OmniSharpNavigateUp<cr>
"navigate down by method/property/field
autocmd FileType cs nnoremap <C-J> :OmniSharpNavigateDown<cr>
augroup END
nnoremap <leader><space> :OmniSharpGetCodeActions<cr>
vnoremap <leader><space> :call OmniSharp#GetCodeActions('visual')<cr>
" rename with dialog
nnoremap <leader>nm :OmniSharpRename<cr>
nnoremap <F2> :OmniSharpRename<cr>
" rename without dialog - with cursor on the symbol to rename... ':Rename newname'
command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>")
" Force OmniSharp to reload the solution. Useful when switching branches etc.
nnoremap <leader>rl :OmniSharpReloadSolution<cr>
nnoremap <leader>cf :OmniSharpCodeFormat<cr>
" Load the current .cs file to the nearest project
nnoremap <leader>tp :OmniSharpAddToProject<cr>
" (Experimental - uses vim-dispatch or vimproc plugin) - Start the omnisharp server for the current solution
nnoremap <leader>ss :OmniSharpStartServer<cr>
nnoremap <leader>sp :OmniSharpStopServer<cr>
" Add syntax highlighting for types and interfaces
nnoremap <leader>th :OmniSharpHighlightTypes<cr>
"Don't ask to save when changing buffers (i.e. when jumping to a type definition)
set hidden
probably VS dont use the same checkers as syntastic ,
run the comand :SyntasticInfo
and it will return what checker it is using them you can find why is those errors comming up and how to make you program pass the syntax checker
obs i dont know visual studio but most of your error are is not a known identifier
maybe is because it is defined in other file and VS checks it but not syntastic checker
I'm running: Windows 7, gvim 7.4
Put this in my vimrc:
"------------dbext--------------
" Microsoft SQL Server
let g:dbext_default_profile_microsoft_production = 'type=SQLSRV:integratedlogin=1:dsnname=SQLOLEDB.1:srvname=SVR:extra=-t'
Tried it with and without the "extra=-t" with the same result:
Here is my entire vimrc:
set nocompatible
set number
set list
set noerrorbells visualbell t_vb=
"gui
set guifont=Consolas:h14
colorscheme blue
"tab and indent settings
set shiftwidth=2
set tabstop=2
set noexpandtab
"split windows
nnoremap <C-k> :exe "vertical resize +10"<CR>
nnoremap <C-j> :exe "vertical resize -10"<CR>
"NERDTree
set autochdir "set working dir to active buffer
let NERDTreeChDirMode=2 "set dir for NERDTree
nnoremap <leader>n :NERDTreeToggle .<CR>
"autocompletion
set omnifunc=syntaxcomplete#Complete
" SuperTab
let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
let g:SuperTabClosePreviewOnPopupClose = 1
"<Ctrl-l> redraws the screen, remove highlighting
set hlsearch
autocmd GUIEnter * set visualbell t_vb=
"directories
set backupdir=C:\G_Drive\code\vim\vimdir
set directory=C:\G_Drive\code\vim\vimdir
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
"pathogen
filetype off "run pathogen before plugin config
execute pathogen#infect()
"call pathogen#runtime_append_all_bundles()
call pathogen#incubate()
call pathogen#helptags()
syntax on
filetype plugin indent on
filetype plugin on
"syntastic
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
" On by default, turn it off for html
"let g:syntastic_mode_map = { 'mode': 'active',
" \ 'active_filetypes': [], }
" \ 'passive_filetypes': ['html'] }
"let g:syntastic_jshint_exec='$HOME/AppData/Roaming/npm/jshint.cmd'
"let g:syntastic_jshint_exec='C:/Users/Drupal Intermediate/AppData/Roaming/npm/jshint.cmd'
let g:syntastic_javascript_checkers = ['jshint']
let g:syntastic_html_checkers = ['w3']
let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']
"------------dbext--------------
" Microsoft SQL Server
let g:dbext_default_profile_microsoft_production = 'type=SQLSRV:integratedlogin=1:dsnname=SQLOLEDB.1:srvname=SVR:extra=-t'
set shell=powershell
set shellcmdflag=-command
"info bar
set laststatus=2
set statusline=
set statusline+=file:\ %F%m%h%r\ %y\ \|
set statusline+=buff:\ %n\|
set statusline+=%=
set statusline+=\|row:\ %l\|col:\ %c%V
set statusline+=\|\ %p%%
"maps
nnoremap p :put<cr>
nnoremap <S-Space> :bn<cr>:syntax sync fromstart<cr>
nnoremap <silent> <C-l> :nohl<CR><C-l>
"nnoremap - mzI/* <esc>A */<esc>`z
nnoremap <C-Tab> :set tabstop=2<bar>set noexpandtab<bar>%retab!<cr>
The leading ÿþ characters give it away; that's a byte order mark (hexadecimal 0xFFFE), used for 16-bit Unicode encodings. Vim didn't properly detect that. Read :help 'fileencodings' to learn how to fix that, or just (re-)read the buffer via
:edit! ++enc=ucs-2le
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.
I know this has already been discussed, but the proposed solution is not working for me.
I have this in my .vimrc:
autocmd! BufWritePost .vimrc nested source $MYVIMRC
Since I read that the correct way to source .vimrc inside an autocmd is using autocmd-nested.
Still, everytime I save it I lose colors in powerline
Edit:
here is my .vimrc
filetype off
set rtp+=~/.vim/vundle.git/
call vundle#rc()
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:ctrlp_working_path_mode = 'ra'
" Bundles
"
" original repos on github
"Bundle 'vim-scripts/taglist.vim'
Bundle 'majutsushi/tagbar'
"Bundle 'joonty/vim-phpqa.git'
"Bundle 'joonty/vim-phpunitqf'
Bundle 'joonty/vdebug'
" Php
Bundle 'sumpygump/php-documentor-vim'
Bundle 'sophacles/vim-processing'
Bundle 'nelstrom/vim-visual-star-search'
Bundle 'Lokaltog/powerline'
Bundle 'spolu/dwm.vim'
Bundle 'tpope/vim-unimpaired'
Bundle 'airblade/vim-gitgutter'
Bundle 'kien/ctrlp.vim'
Bundle 'wikitopian/hardmode'
Bundle 'tpope/vim-fugitive'
Bundle 'sbl/scvim'
Bundle 'vim-scripts/bufexplorer'
Bundle 'aaronbieber/quicktask'
Bundle 'vim-scripts/The-NERD-Commenter'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'vim-scripts/HTML-AutoCloseTag'
Bundle 'scrooloose/nerdtree'
"Bundle 'scrooloose/syntastic'
Bundle 'vim-scripts/css_color.vim'
" Color schemes
Bundle 'tomasr/molokai'
Bundle 'altercation/vim-colors-solarized'
Bundle 'vim-scripts/OOP-javascript-indentation'
let g:gitgutter_enabled = 0
set nocompatible "Don't be compatible with vi
" Enable filetype plugin
filetype indent on
filetype plugin on
" Set to auto read when a file is changed from the outside
set autoread
set t_Co=16
set background=dark
set number "Show line numbering
set numberwidth=1 "Use 1 col + 1 space for numbers
" With a map leader it's possible to do extra key combinations
let mapleader = ","
let g:mapleader = ","
" Toggle NERDTree
map <leader>n :NERDTreeToggle<CR>
set backupdir=~/.vim/backup " where to put backup files
set directory=~/.vim/temp " where to put swap files
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e $MYVIMRC<cr>
" When .vimrc is edited, reload it
augroup MyAutoCmd
autocmd!
augroup END
autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
"au! BufWritePost .vimrc nested source %
set title
" Remap esc key
inoremap jk <esc>
" work more logically with wrapped lines
noremap j gj
noremap k gk
set smartcase " search case sensitive if caps on
set showcmd " Display what command is waiting for an operator
autocmd BufNewFile,BufRead /*apache* setfiletype apache
autocmd BufNewFile,BufRead /*lighttpd*.conf setfiletype lighty
autocmd BufNewFile,BufRead {.,_}vimrc set foldmethod=marker
" PhpDocumentor
au BufRead,BufNewFile *.php inoremap <buffer> <leader>p :call PhpDoc()<CR>
au BufRead,BufNewFile *.php nnoremap <buffer> <leader>p :call PhpDoc()<CR>
au BufRead,BufNewFile *.php vnoremap <buffer> <leader>p :call PhpDocRange()<CR>
" Nicer highlighting of completion popup
highlight Pmenu guibg=brown gui=bold
set scrolloff=7 "Set 7 lines to the cursors when moving vertical
set wildmenu "Autocomplete features in the status bar
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hidden "Change buffer without saving
" Backspae config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Search is case insensitive
set hlsearch "Highlight matches to the search
set incsearch "Show best match so far
set magic "Set magic on for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
" Colors and fonts {{{1
set term=screen-256color
syntax enable "Enable syntax hl
syntax on "Enable syntax hl
"colorscheme molokai
"let g:solarized_termcolors=256
colorscheme solarized
set guifont=Envy\ Code\ R\ for\ Powerline
set encoding=utf-8
filetype plugin on
"set guifont=Inconsolata\ for\ Powerline\
let g:Powerline_symbols="fancy"
" Text, tab and indent related {{{1
set expandtab "Transform tabs into spaces
set shiftwidth=4 "sw 4 spaces (used on auto indent)
set shiftwidth=4 "sw 4 spaces (used on auto indent)
set tabstop=4 "4 spaces as a tab for bs/del
set smarttab
set wrap linebreak tw=80 wm=0 "Wrap lines
set ai "Auto indent
set si "Smart indent
" }}}1
" Moving around, tabs and buffers {{{1
" Move to previous and next buffer
:nmap <C-n> :bnext<CR>
:nmap <C-p> :bprev<CR>
" Map space to / (search) and c-space to ? (backwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Mappings to access buffers (don't use "\p" because a
" delay before pressing "p" would accidentally paste).
" ,l : list buffers
" ,b ,f ,g : go back/forward/last-used
" ,1 ,2 ,3 : go to buffer 1/2/3 etc
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" Close the current buffer. Bclose defined below.
" dovrebbe già esistere in bufkill.vim
" map <leader>bd :Bclose<cr>
" Use the arrows to do something useful
map <right> :bn<cr>
map <left> :bp<cr>
" MiniBufExplorer settings
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 2
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
" Change directory to the file I'm editing
"autocmd BufEnter * lcd %:p:h
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
" Function to close buffer?
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Always hide the statusline
set laststatus=2
" Format the statusline
set statusline=\ %F%m%r%h\ %w\ \ [%Y]\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
"set statusline=%F%m%w\ Line:\ %l\/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%Y]\ [\%03.3b]\[\%02.2B]
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
" tab labels show the filename without path(tail)
set guitablabel=%N/\ %t\ %M
""" Windows
if exists(":tab") " Try to move to other windows if changing buf
set switchbuf=useopen,usetab
else " Try other windows & tabs if available
set switchbuf=useopen
endif
"""" Messages, Info, Status
set shortmess+=a " Use [+] [RO] [w] for modified, read-only, modified
set report=0 " Notify me whenever any lines have changed
set confirm " Y-N-C prompt if closing with unsaved changes
" we don't want to edit these type of files
set wildignore=*.o,*.obj,*.bak,*.exe,*.pyc,*.swp
"""" Coding
set history=1000 " 1000 Lines of history
set showfulltag " Show more information while completing tags
" taglist plugin settings
"nnoremap <silent> <F8> :TlistToggle<CR>
let Tlist_Exit_OnlyWindow = 1 "exit if taglist is last window open
let Tlist_Show_One_File = 1 "only show tags for current buffer
let Tlist_Enable_Fold_Column = 0 "no fold column (only showing one file)
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
let g:sparkupNextMapping = '<c-x>'
" SuperTab settings
let g:SuperTabDefaultCompletionType = '<c-x><c-o>'
""""" Folding
set foldmethod=syntax " By default, use syntax to determine folds
set foldlevelstart=99 " All folds open by default
" Function to highlight character beyond column 79
" activate it with ,h
nnoremap <leader>h :call ToggleOverLengthHighlight()<CR>
let g:overlength_enabled = 0
" set the highlight color
highlight OverLength ctermbg=red guibg=red
function! ToggleOverLengthHighlight()
if g:overlength_enabled == 0
match OverLength /\%79v.*/
let g:overlength_enabled = 1
echo 'OverLength highlighting turned on'
else
match
let g:overlength_enabled = 0
echo 'OverLength highlighting turned off'
endif
endfunction
" in visual mode press Ctrl r to start substituting text
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" PHP Code Sniffer binary (default = "phpcs")
let g:phpqa_codesniffer_cmd='vendor/bin/phpcs'
" PHP Mess Detector binary (default = "phpmd")
let g:phpqa_messdetector_cmd='vendor/bin/phpmd'
set relativenumber
" important
" moving around, searching and patterns
" tags
" displaying text
" syntax, highlighting and spelling
" multiple windows
" multiple tab pages
" terminal
" using the mouse
" printing
" messages and info
" selecting text
" editing text
" tabs and indenting
" folding
" diff mode
" mapping
" toggle the tag list
nmap <Leader>tl :TlistToggle<CR>
" reading and writing files
" the swap file
" command line editing
" executing external commands
" running make and jumping to errors
" language specific
" multi-byte characters
" various
" TagList options
" set the names of flags
let tlist_php_settings = 'php;c:class;f:function;d:constant;p:property'
" close all folds except for current file
let Tlist_File_Fold_Auto_Close = 1
" make tlist pane active when opened
let Tlist_GainFocus_On_ToggleOpen = 1
" width of window
let Tlist_WinWidth = 60
" close tlist when a selection is made
let Tlist_Close_On_Select = 1
" show the prototype
let Tlist_Display_Prototype = 1
" show tags only for current buffer
let Tlist_Show_One_File = 1
" Taglist variables
" Display function name in status bar:
let g:ctags_statusline=1
" Automatically start script
let generate_tags=1
" Displays taglist results in a vertical windows:
let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
nnoremap TT :TlistToggle<CR>
map <F4> :TlistToggle<CR>
" Various Taglist display config:
let Tlist_Use_Right_Windows = 1
let Tlist_Compact_Format = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_File_Fold_Auto_Close = 1
" Ctags options
nmap <Leader>tf :call CtagsFind(expand('<cword>'))<CR>
com! -nargs=+ Tf :call CtagsFind("<args>")
" split window and search for tag
nmap <Leader>ts :exe('stj '.expand('<cword>'))<CR>
set tags=tags;/
" open new tab and search for tag
"
fun! CtagsFind(keyword)
tabe
exe "tj ".a:keyword
endfunction
" TagBar
nmap <F8> :TagbarToggle<CR>
" CtrlP
let g:ctrlp_map = ',t'
nnoremap <silent> ,t :CtrlP<CR>
Your autocmd will be appended to your vim events.
You need handle reload with using augroup.
augroup MyAutoCmd
autocmd!
autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END