Reloading .vimrc in autocmd breaks Powerline - vim

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

Related

Vim substitutes only first occurence in line (global tag not working) [duplicate]

I've been making a lot of changes to my .vimrc lately, and somewhere along the line I've introduced an undesirable feature. When performing a substitution command where the search token appears more than once per line, only the first token is changed (although the remaining tokens are highlighted as a result of the substitution). I have seen a few posts here about how to enable this behavior on a case-by-case basis, but I have yet to see something about what would cause this to be the default behavior or how to disable it. If anyone has any ideas, they would be appreciated.
For reference, my .vimrc (https://github.com/chpatton013/dotfiles/blob/master/vim/.vimrc):
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reread configuration of Vim if .vimrc is saved
augroup VimConfig
au!
au BufWritePost ~/.vimrc so ~/.vimrc
au BufWritePost _vimrc so ~/_vimrc
au BufWritePost vimrc so ~/.vimrc
augroup END
" Set colorcolumn to 80 chars, or (if not supported) highlight lines > 80 chars
augroup ColorColumnConfig
au!
if exists('+colorcolumn')
au BufWinEnter * set colorcolumn=80
au BufWinEnter * hi ColorColumn ctermbg=lightgrey guibg=lightgrey
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
augroup END
" Highlight over-length characters and trailing whitespace
augroup ExtraCharacters
au!
au ColorScheme * highlight ExtraWhitespace ctermbg=Red guibg=Red
au ColorScheme * highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
au BufWinEnter * let w:whitespace_match_number =
\ matchadd('ExtraWhitespace', '\s\+$')
au BufWinEnter * call matchadd('OverLength',
\ '\(^\(\s\)\{-}\(*\|//\|/\*\)\{1}\(.\)*\(\%81v\)\)\#<=\(.\)\{1,}$')
au InsertEnter * call s:ToggleWhitespaceMatch('i')
au InsertLeave * call s:ToggleWhitespaceMatch('n')
augroup END
" Resize splits on window resize
au VimResized * exe "normal! \<c-w>="
" Restore the cursor when we can.
au BufWinEnter * call RestoreCursor()
" Change the statusline color based on current mode
augroup StatuslineColor
au!
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline ctermfg=cyan ctermbg=black guifg=cyan guibg=black
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pathogen - https://github.com/tpope/vim-pathogen
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" Easymotion - https://github.com/Lokaltog/vim-easymotion/
" This is so much more convenient
let g:EasyMotion_leader_key=',m'
" Neocomplcache - https://github.com/Shougo/neocomplcache
" Enable at startup.
let g:neocomplcache_enable_at_startup=1
" Only display 'n' items in the list.
let g:neocomplcache_max_list=5
" Do not auto-select the first candidate.
let g:neocomplcache_enable_auto_select=1
" Do not try to match until 'n' characters have been typed
let g:neocomplcache_auto_completion_start_length=3
" Do not try to match to anything less than 'n' characters
let g:neocomplcache_min_keyword_length=6
let g:neocomplcache_min_syntax_length=6
" Only consider case if an uppercase character has been typed
let g:neocomplcache_enable_smart_case=1
" Syntastic - https://github.com/scrooloose/syntastic/
" Commands:
" :Errors // pop up location list and display errors
" :SyntasticToggleMode // toggles between active and passive mode
" :SyntasticCheck // forces a syntax check in passive mode
" check for syntax errors on file open
let g:syntastic_check_on_open=1
" echo errors to the command window
let g:syntastic_echo_current_error=1
" mark lines with errors and warnings
let g:syntastic_enable_signs=1
" set sign symbols
let g:syntastic_error_symbol='E>'
let g:syntastic_warning_symbol='W>'
let g:syntastic_style_error_symbol='S>'
let g:syntastic_style_warning_symbol='s>'
" open error balloons when moused over erroneous lines
let g:syntastic_enable_balloons=1
" customize Syntastic statusline
let g:syntastic_stl_format = '[%E{E: %fe #%e}%B{, }%W{W: %fw #%w}]'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
let _s=#/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let #/=_s
call cursor(l, c)
endfunction
" Toggle match of trailing whitespace
function! s:ToggleWhitespaceMatch(mode)
let pattern = (a:mode == 'i') ? '\s\+\%#\#<!$' : '\s\+$'
if exists('w:whitespace_match_number')
call matchdelete(w:whitespace_match_number)
call matchadd('ExtraWhitespace', pattern, 10, w:whitespace_match_number)
else
" Something went wrong, try to be graceful.
let w:whitespace_match_number = matchadd('ExtraWhitespace', pattern)
endif
endfunction
" Restore the cursor when we can
function! RestoreCursor()
if line("'\"") <= line("$")
normal! g`"
normal! zz
endif
endfunction
" Change the statusline color based on current mode
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline ctermfg=darkmagenta ctermbg=black guifg=darkmagenta guibg=black
elseif a:mode == 'r'
hi statusline ctermfg=darkgreen ctermbg=black guifg=darkgreen guibg=black
else
hi statusline ctermfg=darkred ctermbg=black guifg=darkred guibg=black
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Configuration customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" gui configuration (do not move from top of configurations)
set guioptions=am
set guifont=Consolas:h9
set encoding=utf-8
set fileencoding=utf-8
set nocompatible " No compatibility with vi.
filetype on " Recognize syntax by file extension.
filetype indent on " Check for indent file.
filetype plugin on " Allow plugins to be loaded by file type.
behave xterm " Maintain keybindings across enviornments
set autowrite " Write before executing the 'make' command.
set background=dark " Background light, so foreground not bold.
set backspace=indent,eol,start " Allow <BS> to go over indents, eol, and start of insert
set expandtab " Expand tabs with spaces.
set nofoldenable " Disable folds; toggle with zi.
set gdefault " Assume :s uses /g.
set hidden " Use hidden buffers so unsaved buffers can go to the background
set history=500 " Set number of lines for vim to remember
set hlsearch " Highlight all search matches
set ignorecase " Ignore case in regular expressions
set incsearch " Immediately highlight search matches.
set laststatus=2 " Show status line even where there is only one window
set lazyredraw " Redraw faster
set linespace=-1 " Bring lines closer together vertically
set modeline " Check for a modeline.
set noerrorbells " No beeps on errors.
set nohls " Don't highlight all regex matches.
set nowrap " Don't soft wrap.
set number " Display line numbers.
set path=~/Code/** " Set default path
set scrolloff=5 " Keep min of 'n' lines above/below cursor.
set shellslash " Use forward slashes regardless of OS
set shiftwidth=3 " >> and << shift 3 spaces.
set showcmd " Show partial commands in the status line.
set showmatch " Show matching () {} etc..
set showmode " Show current mode.
set sidescrolloff=10 " Keep min of 'n' columns right/left cursor.
set smartcase " Searches are case-sensitive if caps used.
set smarttab " Tabs and backspaces at the start of a line indent the line one level
set smartindent " Maintains most indentation and adds extra level when nesting
set softtabstop=3 " See spaces as tabs.
set splitright splitbelow " Open splits below and to the right
set synmaxcol=160 " Only matches syntax on first 'n' columns of each line ( faster)
set tabstop=3 " <Tab> move three characters
set textwidth=79 " Hard wrap at 79 characters
set title " Set the console title
set viminfo='20,\"500,% " Adjust viminfo contents
set virtualedit=block " Allow the cursor to go where it should not
set wildmenu " Tab completion opens a Tab- and arrow-navigable menu
set wildmode=longest,full " Tab completion works like bash.
set wrapscan " Searching wraps to start of file when end is reached
" Define statusline
set statusline=%f " Relative file path
set statusline+=%(\ [%M%R%H%W]%) " File flags (mod, RO, help, preview)
set statusline+=%(\ %<%) " Start truncation
set statusline+=%(\ %{fugitive#statusline()}%) " Git branch name (if applicable)
set statusline+=%= " Begin right justification
set statusline+=%#warningmsg# " Start warning highlighting
set statusline+=%(\ %{SyntasticStatuslineFlag()}%) " Show Syntastic errors and warnings
set statusline+=%* " End warning highlighting
set statusline+=\ [line\ %l\/%L,\ col\ %c%V,\ %p%%] " Line and column numbers and percentage through file
" Text formatting settings
" t: Auto-wrap text using textwidth. (default)
" c: Auto-wrap comments; insert comment leader. (default)
" q: Allow formatting of comments with "gq". (default)
" r: Insert comment leader after hitting <Enter>.
" o: Insert comment leader after hitting 'o' or 'O' in command mode.
" n: Auto-format lists, wrapping to text *after* the list bullet char.
" l: Don't auto-wrap if a line is already longer than textwidth.
set formatoptions+=ronl
" Enable mouse scrolling in selected modes
" a: All
" c: Command
" i: Insert
" n: Normal
" v: Visual
set mouse=a
" Set scrolling to be single-line
"map <MouseDown> <C-Y>
"map <S-MouseDown> <C-U>
"map <MouseUp> <C-E>
"map <S-MouseUp> <C-D>
" Highlighting
syntax enable
set t_Co=16
colorscheme solarized
" Configuration variables
let loaded_matchparen=0 " do automatic bracket highlighting.
let mapleader="," " Use , instead of \ for the map leader.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Command mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make y behave like all other capitals
map Y y$
" Make Q reformat text.
noremap Q gq
" Toggle paste mode.
noremap <Leader>p :set paste!<CR>
" Open the file under the cursor in a new tab.
noremap <Leader>ot <C-W>gf
" Toggle highlighting of the last search.
noremap <Leader>h :set hlsearch! hlsearch?<CR>
" Open a scratch buffer.
noremap <Leader>s :Scratch<CR>
" Improve movement on wrapped lines
nnoremap j gj
nnoremap k gk
" Keep search pattern at the center of the screen
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
nnoremap <silent> g# g#zz
" Use C-hjkl in to change windows
nnoremap <C-h> <C-w><Left>
nnoremap <C-j> <C-w><Down>
nnoremap <C-k> <C-w><Up>
nnoremap <C-l> <C-w><Right>
" Strip trailing whitespace
nnoremap <silent> <leader>W :call <SID>StripTrailingWhitespaces()<CR>
" Allow easy toggling of spaces / tabs mode
nnoremap <C-t><C-t> :set invexpandtab<CR>
" Create simple toggles for line numbers, paste mode, and word wrap.
nnoremap <C-N><C-N> :set invnumber<CR>
nnoremap <C-p><C-p> :set invpaste<CR>
nnoremap <C-w><C-w> :set invwrap<CR>
" Folding stuff
nnoremap <C-o> zo
nnoremap <C-c> zc
nnoremap <C-O> zO
nnoremap <C-O><C-O> zR
set foldmethod=indent
" Open file for class name under cursor
nnoremap <C-i> yiw:find <C-R>".php<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Insert mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set up dictionary completion.
set dictionary+=~/.vim/dictionary/english-freq
set complete+=k
" Smash Esc
inoremap jk <Esc>
inoremap kj <Esc>
" Use hjkl in insert mode
imap <C-h> <Left>
imap <C-j> <Down>
imap <C-k> <Up>
imap <C-l> <Right>
" Make C-s write the buffer and return to insert mode when applicable
inoremap <C-s> <C-O>:w<CR>
nnoremap <C-s> :w<CR>
" auto-insert second braces and parynthesis
inoremap {<CR> {<CR>}<Esc>O
inoremap ({<CR> ({<CR>});<Esc>O
inoremap <<<<CR> <<<EOT<CR>EOT;<Esc>O<C-TAB><C-TAB><C-TAB>
set cpoptions+=$ "show dollar sign at end of text to be changed
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" reselect visual block after indent/outdent
xnoremap < <gv
xnoremap > >gvo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
And the following plugins make up the contents of my bundle directory (https://github.com/chpatton013/dotfiles/tree/master/vim/.vim/bundle):
neocomplcache/
syntastic/
vim-abolish/
vim-colors-solarized/
vim-commentary/
vim-easymotion/
vim-fugitive/
vim-pathogen/
vim-repeat/
vim-surround/
Finally, I have disabled all plugins, but the issue was not resolved. I removed my .vimrc and the issue was resolved (so it is not some global setting outside of my control). I disabled several individual settings in my .vimrc, but I could not seem to eliminate the problem. Eventually, I got tired of playing whack-a-mole and decided to turn to the community. Any ideas?
EDIT: As an example,
I use the command :%s/foo/foobar/g
The text foo bar foo is converted to foobar bar foo
EDIT: Resolved by pb2q. set gdefault inverts the behavior of /g.
The substitute command accepts the switch g, for global, which causes the substitution to be made on all matches on the line:
:s/regex/replacement/g
The default is that only the first occurrence of the match is substituted, but there's a setting to switch the default to global: gdefault. So set gdefault in your vimrc if you want this as the default behavior. Try it out first in the current vim session with :set gdefault.
Note that when you set gdefault, this not only makes g the default behavior, but it changes the usage of the g flag so that using /g at the end of a substitute will cause the substitution to be made only once.
See: :help gdefault.

Vim freezes after pressing CTRL-U in insert mode. Any suggestions?

Recently I figured out that pressing CTRL-U locks/freezes vim in insert mode. The only CTRL-C helps to get it back. Terminal version and gvim have the same behaviour. Only in virtual console mode (CTRL-ALT-F1) the C-U works properly. Here is my .vimrc:
" This must be first, because it changes other options as a side effect.
set nocompatible
" 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.
imap <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
" 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
" Options
" =========================================================
colorscheme gruvbox
let g:gruvbox_contrast_dark = 'normal'
set background=dark
set t_Co=256
" spelling
set spell spelllang=ru_yo,en_us
set spellsuggest=10
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
" backup
set writebackup " backup on write
set nobackup " keep a backup file
set undofile " keep an undo file
set swapfile " keep a swap file
" directories
" set autochdir
set backupdir=~/.vim/tmp/backup//
set undodir=~/.vim/tmp/undo//
set directory=~/.vim/tmp/swp//
" active editor
set nowrap
set nu
set backspace=indent,eol,start " backspacing over everything in im
set ruler " show the cursor position all the time
" cmd
set history=50 " keep 50 lines of command line history
set showcmd " display incomplete commands
" search
set ignorecase " ignore case using a search pattern.
set smartcase " override 'ignorecase' when pattern has upper case.
set incsearch " do incremental searching
" tab
" set tabstop=2 shiftwidth=2 noexpandtab " n-column tab
set tabstop=2 shiftwidth=2 expandtab " n-space character tab
" window
set splitbelow
set splitright
set winminheight=0
" folding settings
set foldmethod=indent " fold based on indent
set foldnestmax=10 " deepest fold is 10 levels
set nofoldenable " dont fold by default
set foldlevel=1 " this is just what i use
" invisible chars
set list " don't show invisible characters.
set listchars=tab:.\ ,trail:~,extends:>,precedes:<,eol:\ "¬
set nohidden " unload buffer when no longer shown in window.
set laststatus=2 " Display vim-lightline
" indent, cursor, width
set cursorline " Highlight the screen line of the cursor.
set colorcolumn=72 " Columan to highlight.
set autoindent " Automatically set the indent of a new line.
set textwidth=80
set completeopt=menuone,longest ",preview prevents immediate complete
" tab
set switchbuf=usetab " use window or tabs to find selected buff
" windows
set noea " fix window size after closing others
" sessions (^blank,help)
set sessionoptions=buffers,curdir,folds,help,options,tabpages,winsize
" Autocmd
" =========================================================
au BufReadPost *.tmpl set syntax=html
" Mappings
" =========================================================
" source and update file
nmap <F5> :so ~/.vimrc<CR>
nmap <leader>e :e<CR>
" copy filepath
nmap <silent> <F4> :let #+=expand("%:p")<CR>
" buffers
nmap <F2> :ls<CR>:b
nmap <c-w><c-t> :tabnew<CR>
nmap <c-w><c-e> :tab sp<CR>
nmap <c-w><c-b>n :tabnew %<Bar>:bNext<Bar><CR>
nmap <c-w><c-b><c-b> :bw %<CR>
nmap <c-w><c-b>w :bw! %<CR>
nmap <c-w><c-b>a :tab ball<CR>
" sessions
nmap <silent> <leader>ss :wa<Bar>exe "mksession! " . v:this_session<CR>
nmap <leader>sr :so .session.vim<CR>
nmap <leader>sc :msk .session.vim<CR>
" quit
nmap <leader>qd :qa!<CR> " quit & discard changes
nmap <leader>qq :xa<CR> " quit & write if changed
nmap <leader>qs <leader>s<leader>qd
" new vertical window
nmap <c-w><c-n> :vnew<CR>
" tab movement and switching
nmap <c-l> :tabnext<CR>
nmap <c-h> :tabprevious<CR>
nmap <c-j> :tabmove -1<CR>
nmap <c-k> :tabmove +1<CR>
" search and replace
nmap <leader>c :let #/=""<CR>
" trailing spaces
nmap <silent> <leader>dt mq:%s/\s\+$//e<Bar>:let #/=""<CR>`q:delm q<CR>
" update, write
nmap <leader>u <leader>dt:update<CR>
nmap <leader>w <leader>dt:write<CR>
cmap w!! w !sudo tee > /dev/null %
" window manipulation
nmap <c-w>== :set ead=ver ea noea<CR>
nmap <c-w>=- :set ead=hor ea noea<CR>
" shell
nmap <space> :sh<CR>
" Plugins
" =========================================================
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
Plug 'mattn/emmet-vim'
Plug 'itchyny/lightline.vim'
Plug 'sheerun/vim-polyglot'
Plug 'scrooloose/syntastic'
call plug#end()
" Lightline.vim
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename', 'readonly', 'modified' ] ] },
\}
" Syntastic
" let g:syntastic_sass_checkers = ["sassc"]
" Netrw
nmap <leader>tr <Plug>NetrwRefresh
map <leader>tf :Ntree<CR>
map <silent> <leader>f <S-CR>
let g:netrw_liststyle=3
let g:netrw_banner=0
let g:netrw_mousemaps=0
let g:netrw_chgwin=1 " open files in left window by default
" let g:netrw_keepdir=0
" let g:netrw_silent= 1
" fire up the sidebar
nmap <silent> <C-#> :rightbelow 25vs<CR>:e .<CR>
" vim-go
" disable fmt on save
let g:go_fmt_autosave = 0
" format with goimports instead of gofmt
let g:go_fmt_command = "goimports"
" additional highlight
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" YouCompleteMe
let g:ycm_confirm_extra_conf=0
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_min_num_of_chars_for_completion=1
" Emmet-vim
let g:user_emmet_leader_key='<c-m>'
" Formats the statusline
" set statusline=%f " file name
" set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
" set statusline+=%{&ff}] "file format
" set statusline+=%y "filetype
" set statusline+=%h "help file flag
" set statusline+=%m "modified flag
" set statusline+=%r "read only flag
"
" set statusline+=\ %= " align left
" set statusline+=Line:%l/%L[%p%%] " line X of Y [percent of file]
" set statusline+=\ Col:%c " current column
" set statusline+=\ Buf:%n " Buffer number
" set statusline+=\ [%b][0x%B]\ " ASCII and byte code under cursor
" Miscellaneous
" =========================================================
nmap <leader>t :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
:set guioptions-=m "remove menu bar
:set guioptions-=T "remove toolbar
:set guioptions-=r "remove right-hand scroll bar
:set guioptions-=L "remove left-hand scroll bar
It's quite big, but the only one mapping related with C-U: imap <C-U> <C-G>u<C-U>. What's going on?
I've copied your vimrc and used it. Same effect. It's this line:
imap <C-U> <C-G>u<C-U>
which apparently causes a recursion. When commented out, <C-u> erases back to start-of-line.
Given the problem that #Jens found... you, Timur, might want to try
inoremap <c-u> <c-g>u<c-u>
That will prevent remapping (ie. an infinite recursion) from taking place.

How to hide all source code tooltips in MacVim?

I installed MacVim 7.4-73_1 on MacOs X Yosemite using Homebrew. When in a ruby file hovering over certain words will cause a tooltip to fade in. It seems to slow Vim down causing a short lag while the tooltip loads, they also tend to get in the way. So, my goal is to hide these tooltips all together. I understand this may be caused by a plugin I am using but I can't seem to pin it down.
I have attached a gif below showing another strange behavior. The tooltips only show up if I begin editing a file from the vim explorer.
Below is a list of the vim plugins I am using and my .vimrc
All my plugins
ack.vim
mustache
nerdcommenter
sass-convert.vim
snipmate-mocha
snipmate-snippets
tabular
tlib_vim
vim-addon-mw-utils
vim-coffee-script
vim-css-color
vim-fugitive
vim-less
vim-rails
vim-rspec
vim-snipmate
My Vimrc File
" Use Pathogen
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" ================
" Ruby stuff
" ================
syntax on " Enable syntax highlighting
filetype plugin indent on " Enable filetype-specific indenting and plugins
augroup myfiletypes
" Clear old autocmds in group
autocmd!
" autoindent with two spaces, always expand tabs
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
augroup END
"================
let mapleader = ","
" START html.tidy
:vmap <Leader>ti :!tidy -q -i --show-errors 0<CR>
" START TAB.vim
nmap <Leader>a{ :Tabularize /{<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a. :Tabularize /=><CR>
vmap <Leader>a. :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
"inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
function! s:ealign()
let p = '^.*=[^>]*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
"inoremap <silent> => =><Esc>:call <SID>ralign()<CR>a
function! s:ralign()
let p = '^.*=>*$'
if exists(':Tabularize') && getline('.') =~# '^.*=>' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=>]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=>\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=>]*=>',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
inoremap <silent> <Bar> <Bar><Esc>:call <SID>palign()<CR>a
function! s:palign()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" END TAB.vim
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
" START rspec.vim
"map <Leader>t :call RunCurrentSpecFile()<CR>
"map <Leader>s :call RunNearestSpec()<CR>
"map <Leader>l :call RunLastSpec()<CR>
map <Leader>ra :call RunAllSpecs()<CR>
" END rspec.vim
set nocompatible
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set autoindent " indent next line
set showmatch " Attempts to show matching (), {}, or []
set nowrap
"set nobackup
"set noswapfile
set backupdir=~/.tmp
set directory=~/.tmp " Don't clutter my dirs up with swp and tmp files
set autoread
set wmh=0 " This sets the minimum window height to 0, so you can stack many more files before things get crowded. Vim will only display the filename.
set viminfo+=!
" Edit another file in the same directory as the current file
" uses expression to extract path from current file's path
map <Leader>e :Explore
map <Leader>ep :e <C-R>=expand("%:p:h") . '/'<CR>
map <Leader>s :Sexplore
map <Leader>v :Vexplore
map <Leader>nt :tabe <C-R>=expand("%:p:h") . '/'<CR>
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
vmap <leader>h :!/Users/ross/.rvm/bin/vim_html2haml<cr>
function! PasteAsCoffee()
:read !pbpaste | js2coffee
endfunction
:command! PasteAsCoffee :call PasteAsCoffee()
:map <leader>pc :PasteAsCoffee<CR>
set tabstop=2 " Set tabs to 2 spaces
set autowriteall " Auto save on close
set spell
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:. " Highlight problematic whitespace
set et " expand tab
set sw=2 " shift width < >
set smarttab " deltes of adds a tab
set tw=80 " auto break lines at 80 columns
set incsearch " don't show search matches as you type
set ignorecase smartcase " when searching ignore case when the pattern contains lowercase letters only.
set laststatus=2 " show status line. never=0 only when split=1 always=2
set number " show line numbers
set gdefault " assume the /g flag on :s substitutions to replace all matches in a line
set autoindent " always set autoindenting on
set pastetoggle=<F2> " Don't auto indent pasted text after F2
let g:netrw_preview = 1
let g:fuzzy_ignore = ".DS_Store;*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**"
set nofoldenable " Say no to code folding...
set statusline+=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
" I don't remember what this does
autocmd BufEnter * silent! lcd %:p:h
" remove search highlight with ,/
nmap <silent> ,/ :nohlsearch<CR>
" 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
endif " has("autocmd")
colors codeschool
You can read about that feature in :help balloon-eval.
That option is disabled by default so one of your plugins probably enabled it. This command should show you which one is the culprit:
:verbose set ballooneval?
You can disable that feature with :set noballooneval.

What causes substitution in Vim to only match one element per line?

I've been making a lot of changes to my .vimrc lately, and somewhere along the line I've introduced an undesirable feature. When performing a substitution command where the search token appears more than once per line, only the first token is changed (although the remaining tokens are highlighted as a result of the substitution). I have seen a few posts here about how to enable this behavior on a case-by-case basis, but I have yet to see something about what would cause this to be the default behavior or how to disable it. If anyone has any ideas, they would be appreciated.
For reference, my .vimrc (https://github.com/chpatton013/dotfiles/blob/master/vim/.vimrc):
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reread configuration of Vim if .vimrc is saved
augroup VimConfig
au!
au BufWritePost ~/.vimrc so ~/.vimrc
au BufWritePost _vimrc so ~/_vimrc
au BufWritePost vimrc so ~/.vimrc
augroup END
" Set colorcolumn to 80 chars, or (if not supported) highlight lines > 80 chars
augroup ColorColumnConfig
au!
if exists('+colorcolumn')
au BufWinEnter * set colorcolumn=80
au BufWinEnter * hi ColorColumn ctermbg=lightgrey guibg=lightgrey
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
augroup END
" Highlight over-length characters and trailing whitespace
augroup ExtraCharacters
au!
au ColorScheme * highlight ExtraWhitespace ctermbg=Red guibg=Red
au ColorScheme * highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
au BufWinEnter * let w:whitespace_match_number =
\ matchadd('ExtraWhitespace', '\s\+$')
au BufWinEnter * call matchadd('OverLength',
\ '\(^\(\s\)\{-}\(*\|//\|/\*\)\{1}\(.\)*\(\%81v\)\)\#<=\(.\)\{1,}$')
au InsertEnter * call s:ToggleWhitespaceMatch('i')
au InsertLeave * call s:ToggleWhitespaceMatch('n')
augroup END
" Resize splits on window resize
au VimResized * exe "normal! \<c-w>="
" Restore the cursor when we can.
au BufWinEnter * call RestoreCursor()
" Change the statusline color based on current mode
augroup StatuslineColor
au!
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline ctermfg=cyan ctermbg=black guifg=cyan guibg=black
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pathogen - https://github.com/tpope/vim-pathogen
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" Easymotion - https://github.com/Lokaltog/vim-easymotion/
" This is so much more convenient
let g:EasyMotion_leader_key=',m'
" Neocomplcache - https://github.com/Shougo/neocomplcache
" Enable at startup.
let g:neocomplcache_enable_at_startup=1
" Only display 'n' items in the list.
let g:neocomplcache_max_list=5
" Do not auto-select the first candidate.
let g:neocomplcache_enable_auto_select=1
" Do not try to match until 'n' characters have been typed
let g:neocomplcache_auto_completion_start_length=3
" Do not try to match to anything less than 'n' characters
let g:neocomplcache_min_keyword_length=6
let g:neocomplcache_min_syntax_length=6
" Only consider case if an uppercase character has been typed
let g:neocomplcache_enable_smart_case=1
" Syntastic - https://github.com/scrooloose/syntastic/
" Commands:
" :Errors // pop up location list and display errors
" :SyntasticToggleMode // toggles between active and passive mode
" :SyntasticCheck // forces a syntax check in passive mode
" check for syntax errors on file open
let g:syntastic_check_on_open=1
" echo errors to the command window
let g:syntastic_echo_current_error=1
" mark lines with errors and warnings
let g:syntastic_enable_signs=1
" set sign symbols
let g:syntastic_error_symbol='E>'
let g:syntastic_warning_symbol='W>'
let g:syntastic_style_error_symbol='S>'
let g:syntastic_style_warning_symbol='s>'
" open error balloons when moused over erroneous lines
let g:syntastic_enable_balloons=1
" customize Syntastic statusline
let g:syntastic_stl_format = '[%E{E: %fe #%e}%B{, }%W{W: %fw #%w}]'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
let _s=#/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let #/=_s
call cursor(l, c)
endfunction
" Toggle match of trailing whitespace
function! s:ToggleWhitespaceMatch(mode)
let pattern = (a:mode == 'i') ? '\s\+\%#\#<!$' : '\s\+$'
if exists('w:whitespace_match_number')
call matchdelete(w:whitespace_match_number)
call matchadd('ExtraWhitespace', pattern, 10, w:whitespace_match_number)
else
" Something went wrong, try to be graceful.
let w:whitespace_match_number = matchadd('ExtraWhitespace', pattern)
endif
endfunction
" Restore the cursor when we can
function! RestoreCursor()
if line("'\"") <= line("$")
normal! g`"
normal! zz
endif
endfunction
" Change the statusline color based on current mode
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline ctermfg=darkmagenta ctermbg=black guifg=darkmagenta guibg=black
elseif a:mode == 'r'
hi statusline ctermfg=darkgreen ctermbg=black guifg=darkgreen guibg=black
else
hi statusline ctermfg=darkred ctermbg=black guifg=darkred guibg=black
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Configuration customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" gui configuration (do not move from top of configurations)
set guioptions=am
set guifont=Consolas:h9
set encoding=utf-8
set fileencoding=utf-8
set nocompatible " No compatibility with vi.
filetype on " Recognize syntax by file extension.
filetype indent on " Check for indent file.
filetype plugin on " Allow plugins to be loaded by file type.
behave xterm " Maintain keybindings across enviornments
set autowrite " Write before executing the 'make' command.
set background=dark " Background light, so foreground not bold.
set backspace=indent,eol,start " Allow <BS> to go over indents, eol, and start of insert
set expandtab " Expand tabs with spaces.
set nofoldenable " Disable folds; toggle with zi.
set gdefault " Assume :s uses /g.
set hidden " Use hidden buffers so unsaved buffers can go to the background
set history=500 " Set number of lines for vim to remember
set hlsearch " Highlight all search matches
set ignorecase " Ignore case in regular expressions
set incsearch " Immediately highlight search matches.
set laststatus=2 " Show status line even where there is only one window
set lazyredraw " Redraw faster
set linespace=-1 " Bring lines closer together vertically
set modeline " Check for a modeline.
set noerrorbells " No beeps on errors.
set nohls " Don't highlight all regex matches.
set nowrap " Don't soft wrap.
set number " Display line numbers.
set path=~/Code/** " Set default path
set scrolloff=5 " Keep min of 'n' lines above/below cursor.
set shellslash " Use forward slashes regardless of OS
set shiftwidth=3 " >> and << shift 3 spaces.
set showcmd " Show partial commands in the status line.
set showmatch " Show matching () {} etc..
set showmode " Show current mode.
set sidescrolloff=10 " Keep min of 'n' columns right/left cursor.
set smartcase " Searches are case-sensitive if caps used.
set smarttab " Tabs and backspaces at the start of a line indent the line one level
set smartindent " Maintains most indentation and adds extra level when nesting
set softtabstop=3 " See spaces as tabs.
set splitright splitbelow " Open splits below and to the right
set synmaxcol=160 " Only matches syntax on first 'n' columns of each line ( faster)
set tabstop=3 " <Tab> move three characters
set textwidth=79 " Hard wrap at 79 characters
set title " Set the console title
set viminfo='20,\"500,% " Adjust viminfo contents
set virtualedit=block " Allow the cursor to go where it should not
set wildmenu " Tab completion opens a Tab- and arrow-navigable menu
set wildmode=longest,full " Tab completion works like bash.
set wrapscan " Searching wraps to start of file when end is reached
" Define statusline
set statusline=%f " Relative file path
set statusline+=%(\ [%M%R%H%W]%) " File flags (mod, RO, help, preview)
set statusline+=%(\ %<%) " Start truncation
set statusline+=%(\ %{fugitive#statusline()}%) " Git branch name (if applicable)
set statusline+=%= " Begin right justification
set statusline+=%#warningmsg# " Start warning highlighting
set statusline+=%(\ %{SyntasticStatuslineFlag()}%) " Show Syntastic errors and warnings
set statusline+=%* " End warning highlighting
set statusline+=\ [line\ %l\/%L,\ col\ %c%V,\ %p%%] " Line and column numbers and percentage through file
" Text formatting settings
" t: Auto-wrap text using textwidth. (default)
" c: Auto-wrap comments; insert comment leader. (default)
" q: Allow formatting of comments with "gq". (default)
" r: Insert comment leader after hitting <Enter>.
" o: Insert comment leader after hitting 'o' or 'O' in command mode.
" n: Auto-format lists, wrapping to text *after* the list bullet char.
" l: Don't auto-wrap if a line is already longer than textwidth.
set formatoptions+=ronl
" Enable mouse scrolling in selected modes
" a: All
" c: Command
" i: Insert
" n: Normal
" v: Visual
set mouse=a
" Set scrolling to be single-line
"map <MouseDown> <C-Y>
"map <S-MouseDown> <C-U>
"map <MouseUp> <C-E>
"map <S-MouseUp> <C-D>
" Highlighting
syntax enable
set t_Co=16
colorscheme solarized
" Configuration variables
let loaded_matchparen=0 " do automatic bracket highlighting.
let mapleader="," " Use , instead of \ for the map leader.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Command mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make y behave like all other capitals
map Y y$
" Make Q reformat text.
noremap Q gq
" Toggle paste mode.
noremap <Leader>p :set paste!<CR>
" Open the file under the cursor in a new tab.
noremap <Leader>ot <C-W>gf
" Toggle highlighting of the last search.
noremap <Leader>h :set hlsearch! hlsearch?<CR>
" Open a scratch buffer.
noremap <Leader>s :Scratch<CR>
" Improve movement on wrapped lines
nnoremap j gj
nnoremap k gk
" Keep search pattern at the center of the screen
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
nnoremap <silent> g# g#zz
" Use C-hjkl in to change windows
nnoremap <C-h> <C-w><Left>
nnoremap <C-j> <C-w><Down>
nnoremap <C-k> <C-w><Up>
nnoremap <C-l> <C-w><Right>
" Strip trailing whitespace
nnoremap <silent> <leader>W :call <SID>StripTrailingWhitespaces()<CR>
" Allow easy toggling of spaces / tabs mode
nnoremap <C-t><C-t> :set invexpandtab<CR>
" Create simple toggles for line numbers, paste mode, and word wrap.
nnoremap <C-N><C-N> :set invnumber<CR>
nnoremap <C-p><C-p> :set invpaste<CR>
nnoremap <C-w><C-w> :set invwrap<CR>
" Folding stuff
nnoremap <C-o> zo
nnoremap <C-c> zc
nnoremap <C-O> zO
nnoremap <C-O><C-O> zR
set foldmethod=indent
" Open file for class name under cursor
nnoremap <C-i> yiw:find <C-R>".php<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Insert mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set up dictionary completion.
set dictionary+=~/.vim/dictionary/english-freq
set complete+=k
" Smash Esc
inoremap jk <Esc>
inoremap kj <Esc>
" Use hjkl in insert mode
imap <C-h> <Left>
imap <C-j> <Down>
imap <C-k> <Up>
imap <C-l> <Right>
" Make C-s write the buffer and return to insert mode when applicable
inoremap <C-s> <C-O>:w<CR>
nnoremap <C-s> :w<CR>
" auto-insert second braces and parynthesis
inoremap {<CR> {<CR>}<Esc>O
inoremap ({<CR> ({<CR>});<Esc>O
inoremap <<<<CR> <<<EOT<CR>EOT;<Esc>O<C-TAB><C-TAB><C-TAB>
set cpoptions+=$ "show dollar sign at end of text to be changed
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual mode customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" reselect visual block after indent/outdent
xnoremap < <gv
xnoremap > >gvo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
And the following plugins make up the contents of my bundle directory (https://github.com/chpatton013/dotfiles/tree/master/vim/.vim/bundle):
neocomplcache/
syntastic/
vim-abolish/
vim-colors-solarized/
vim-commentary/
vim-easymotion/
vim-fugitive/
vim-pathogen/
vim-repeat/
vim-surround/
Finally, I have disabled all plugins, but the issue was not resolved. I removed my .vimrc and the issue was resolved (so it is not some global setting outside of my control). I disabled several individual settings in my .vimrc, but I could not seem to eliminate the problem. Eventually, I got tired of playing whack-a-mole and decided to turn to the community. Any ideas?
EDIT: As an example,
I use the command :%s/foo/foobar/g
The text foo bar foo is converted to foobar bar foo
EDIT: Resolved by pb2q. set gdefault inverts the behavior of /g.
The substitute command accepts the switch g, for global, which causes the substitution to be made on all matches on the line:
:s/regex/replacement/g
The default is that only the first occurrence of the match is substituted, but there's a setting to switch the default to global: gdefault. So set gdefault in your vimrc if you want this as the default behavior. Try it out first in the current vim session with :set gdefault.
Note that when you set gdefault, this not only makes g the default behavior, but it changes the usage of the g flag so that using /g at the end of a substitute will cause the substitution to be made only once.
See: :help gdefault.

vimrc split bar movable [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I took my vimrc from a friend and it has some changes to the split bar. How do I restore it to the default split bar?
my .vim folder: here
and .vimrc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: amix the lucky stiff
" http://amix.dk - amix#amix.dk
"
" Version: 3.6 - 25/08/10 14:40:30
"
" Blog_post:
" http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
" Raw_version:
" http://amix.dk/vim/vimrc.txt
"
" How_to_Install_on_Unix:
" $ mkdir ~/.vim_runtime
" $ svn co svn://orangoo.com/vim ~/.vim_runtime
" $ cat ~/.vim_runtime/install.sh
" $ sh ~/.vim_runtime/install.sh <system>
" <sytem> can be `mac`, `linux` or `windows`
"
" How_to_Upgrade:
" $ svn update ~/.vim_runtime
"
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Command mode related
" -> Moving around, tabs and buffers
" -> Statusline
" -> Parenthesis/bracket expanding
" -> General Abbrevs
" -> Editing mappings
"
" -> Cope
" -> Minibuffer plugin
" -> Omni complete functions
" -> Python section
" -> JavaScript section
"
"
" Plugins_Included:
" > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159
" Makes it easy to get an overview of buffers:
" info -> :e ~/.vim_runtime/plugin/minibufexpl.vim
"
" > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42
" Makes it easy to switch between buffers:
" info -> :help bufExplorer
"
" > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234
" Emacs's killring, useful when using the clipboard:
" info -> :help yankring
"
" > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697
" Makes it easy to work with surrounding text:
" info -> :help surround
"
" > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540
" Snippets for many languages (similar to TextMate's):
" info -> :help snipMate
"
" > mru.vim - http://www.vim.org/scripts/script.php?script_id=521
" Plugin to manage Most Recently Used (MRU) files:
" info -> :e ~/.vim_runtime/plugin/mru.vim
"
" > Command-T - http://www.vim.org/scripts/script.php?script_id=3025
" Command-T plug-in provides an extremely fast, intuitive mechanism for opening filesa:
" info -> :help CommandT
" screencast and web-help -> http://amix.dk/blog/post/19501
"
"
" Revisions:
" > 3.6: Added lots of stuff (colors, Command-T, Vim 7.3 persistent undo etc.)
" > 3.5: Paste mode is now shown in status line if you are in paste mode
" > 3.4: Added mru.vim
" > 3.3: Added syntax highlighting for Mako mako.vim
" > 3.2: Turned on python_highlight_all for better syntax
" highlighting for Python
" > 3.1: Added revisions ;) and bufexplorer.vim
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugin
filetype plugin on
filetype indent on
set nocp
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/.vim_runtime/vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curors - when moving vertical..
set so=7
set wildmenu "Turn on WiLd menu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hid "Change buffer - without saving
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
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=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
colorscheme 256-jungle
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"Persistent undo
try
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
set undodir=~/.vim_runtime/undodir
endif
set undofile
catch
endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab
set shiftwidth=2
set tabstop=2
set smarttab
set lbr
set tw=500
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = #"
execute "normal! vgvy"
let l:pattern = escape(#", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let #/ = l:pattern
let #" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
" Useful on some European keyboards
map ½ $
imap ½ $
vmap ½ $
cmap ½ $
func! Cwd()
let cwd = getcwd()
return "e " . cwd
endfunc
func! DeleteTillSlash()
let g:cmd = getcmdline()
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
endif
if g:cmd == g:cmd_edited
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
endif
endif
return g:cmd_edited
endfunc
func! CurrentFileDir(cmd)
return a:cmd . " " . expand("%:p:h") . "/"
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map space to / (search) and c-space to ? (backgwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move btw. 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
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,300 bd!<cr>
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
" Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
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
""""""""""""""""""""""""""""""
" => Statusline
""""""""""""""""""""""""""""""
" Always hide the statusline
set laststatus=2
" Format the statusline
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Parenthesis/bracket expanding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Remap VIM 0
map 0 ^
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"Delete trailing white space, useful for Python ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
set guitablabel=%t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Do :help cope if you are unsure what cope is. It's super useful!
map <leader>cc :botright cope<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>
""""""""""""""""""""""""""""""
" => bufExplorer plugin
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
map <leader>o :BufExplorer<cr>
""""""""""""""""""""""""""""""
" => Minibuffer plugin
""""""""""""""""""""""""""""""
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 2
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 25
let g:miniBufExplSplitBelow=1
let g:bufExplorerSortBy = "name"
autocmd BufRead,BufNew :call UMiniBufExplorer
map <leader>u :TMiniBufExplorer<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Omni complete functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
"Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
""""""""""""""""""""""""""""""
" => Python section
""""""""""""""""""""""""""""""
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set ft=mako
au FileType python inoremap <buffer> $r return
au FileType python inoremap <buffer> $i import
au FileType python inoremap <buffer> $p print
au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
au FileType python map <buffer> <leader>1 /class
au FileType python map <buffer> <leader>2 /def
au FileType python map <buffer> <leader>C ?class
au FileType python map <buffer> <leader>D ?def
""""""""""""""""""""""""""""""
" => JavaScript section
"""""""""""""""""""""""""""""""
au FileType javascript call JavaScriptFold()
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap <c-t> AJS.log();<esc>hi
au FileType javascript imap <c-a> alert();<esc>hi
au FileType javascript inoremap <buffer> $r return
au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), '{.*', '{...}', '')
endfunction
setl foldtext=FoldText()
endfunction
""""""""""""""""""""""""""""""
" => MRU plugin
""""""""""""""""""""""""""""""
let MRU_Max_Entries = 400
map <leader>f :MRU<CR>
""""""""""""""""""""""""""""""
" => Command-T
""""""""""""""""""""""""""""""
let g:CommandTMaxHeight = 15
set wildignore+=*.o,*.obj,.git,*.pyc
noremap <leader>j :CommandT<cr>
noremap <leader>y :CommandTFlush<cr>
""""""""""""""""""""""""""""""
" => Vim grep
""""""""""""""""""""""""""""""
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'
set grepprg=/bin/grep\ -nH
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MISC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
"Quickly open a buffer for scripbble
map <leader>q :e ~/buffer<cr>
au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================
map <leader>pp :setlocal paste!<cr>
map <leader>bb :cd ..<cr>
"setting taglist to be opened at startup
let Tlist_Auto_Open = 1
"mapping keys for auto changing the colorscheme
map <silent><F3> :NEXTCOLOR<cr>
map <silent><F2> :PREVCOLOR<cr>
"to get function parameters shown from autocomplpop
let g:AutoComplPop_CompleteoptPreview = 1
"mapping key to save all the open buffers
map <silent><F4> :wa<cr>
the split bar shows like in the image. While I want it to be movable. What needs to be changed?
Thanks in advance.
You can move the horizontal split bar by pressing control-w follow by 10+ to increase the size of the active window by 10 lines in the vertical directions. (or - to decrease), e.g. move the ruler up or down.
The resize the vertical split bar, you can do something similar: control-w 10> or <. To move the split bar to the left or right.
I don't think this is related to the .vimrc that you give.

Resources