I have been moving my .vimrc file over to windows (see here). I now can not yank anything. For example none of the below do anything
yyp
yjp
ykp
ywp
...
Here are some other problems I am having with gVim under windows. I have included these in case anyone finds them useful
; is mapped to : but q; does not do the same thing as q:
My macro's behave unpredictably. With more complex macros, they keep falling apart
List item
My .vimrc is as follows, in case it helps.
let mapleader = ","
" Swap ; and : Convenient.
nnoremap ; :
nnoremap : ;
"Map jj to escape
inoremap jj <Esc>
" Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>
nnoremap <silent> zk O<Esc>
"Make cursor move as expected with wrapped lines:
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
"Map Shift+ J to previous buffer
noremap J :bp<CR>
"Map Shift + K to next buffer
noremap K :bn<CR>
"Turn on syntax
filetype plugin indent on
syntax on
" Fast saving
noremap <leader>w :w!<cr>
"Default for checking marks is 4 seconds, make it faster
set updatetime=100
"Persistent Undo
" set undodir=~/.vim/undodir
set undodir=c:\\Users\user\vim\undodir
set undofile
set undolevels=10000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
"Keep undo history when switching buffers
set hidden
"Use the smart version of backspace
set backspace=2
"Use spaces instead of tabs
set expandtab
"Line Numbers
set number
"Makes unnamed clipboard accesible to X window
set clipboard=unnamedplus
"Number of spaces to use for each step of (auto)indent.
set shiftwidth=4
"This shows what you are typing as a command
set showcmd
set smarttab
"Indent every time you press enter
set autoindent
"Cursor Always in middle
"NOTE This causes problems with word wrap of long lines as they are not
"displayed correctly
set scrolloff=999
"make word wrap wrap words, not character
set formatoptions=l
set lbr
"Use ... when word wrapping
set showbreak=...
"enable status line always
set laststatus=2
"
" statusline
" cf the default statusline: %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" format markers:
" %< truncation point
" %n buffer number
" %f relative path to file
" %m modified flag [+] (modified), [-] (unmodifiable) or nothing
" %r readonly flag [RO]
" %y filetype [ruby]
" %= split point for left and right justification
" %-35. width specification
" %l current line number
" %L number of lines in buffer
" %c current column number
" %V current virtual column number (-n), if different from %c
" %P percentage through buffer
" %) end of width specification
set statusline=%f%m%r%h%w[%n]\ [F=%{&ff}][T=%Y]\ %=[LINE=%l][%p%%]
"set it up to change the status line based on mode
if version >= 700
au InsertEnter * hi StatusLine term=reverse ctermbg=4
au InsertLeave * hi StatusLine term=reverse ctermbg=2
endif
"start searching as you type
set incsearch
"Highlight search strings
set hlsearch
" Set off the other paren
highlight MatchParen ctermbg=4
"Ignore case when searching
set ignorecase
"But remember case when capitals used
set smartcase
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif
"Show matching brackets when text indicator is over them
set showmatch
"How many tenths of a second to blink
"Does not seem to change anything
set mat=2
"Highlight current line
set cul
"adjust highlight color
hi CursorLine term=none cterm=none ctermbg=232
"enable 256 color
set t_Co=256
"Do not want spell checking in my commented blocks
let g:tex_comment_nospell= 1
if &t_Co == 256
" colorscheme xoria256
colorscheme desert
else
colorscheme peachpuff
endif
" Font size
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h14:cANSI
endif
endif
Hum... First thing that needs to be checked: .vimrc filename under windows for the native version of vim shall be _vimrc, and it shall be placed into your HOME directory.
Then, you don't seem to be using mswin.vim witch is a good thing for those among us that are used to vim. And I don't see anything suspect in your file.
If you can identify odd keybindings, you can play with :verbose imap jj (for instance) to see if everything works as expected.
PS: swapping : and ; is a bad idea: not all plugins are correctly written to use banged-mappings or :normal! in their functions. You'd best to get used to your keyboard, otherwise surprises and misbehaving plugins are to be expected.
Related
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.
In Vim, key k moves the cursor one line up. If I map key e to key k: noremap e k, then when I press e the cursor moves one line up and one position to the right. Why does it happen? Is it some Vim plugin interferes with noremap or I am missing something? How to debug it?
My .vimrc file:
" Use spaces instead of tabs
set expandtab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Set vim to be noncompatible with vi.
" There is no funky behavior with arrow keys this way.
set nocompatible
" Configure backspace so it acts as it should act
set backspace=indent,eol,start
" Solarized color scheme
syntax enable
colorscheme SolarizedDarkCinnamon
" Underline the cursor line.
set cursorline
hi CursorLine term=bold cterm=bold
" allow to copy from and to clipboard
set clipboard=unnamedplus
" Set autoindentation
set autoindent
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
set iminsert=0
set imsearch=0
My guess is that you have a trailing whitespace in your mapping definition. Remove it.
I have begun debugging my .vimrc file after migrating to windows (see related question here). In Ubuntu, I mapped the jj key combination to ESC like so
inoremap jj <Esc>
Although pressing jj does help get me out of insert mode, it tries to seek forward 10 or 15 characters (I haven't actually counted). Here are some other things that may be relevant,
; enters command mode but q; does not give me the command mode history, I have to type q:
I have mapped SHIFT + J (<S-J>) to previous buffer command (bp). It too moves the cursor left/right. Similarly for SHIFT + K (<S-K>) mapped to bn
j and k commands behave normally
It seems to be only with cases where the ENTER or ESC buttons are triggered
Here is my vimrc file in case it helps
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Swap ; and : Convenient.
nnoremap ; :
nnoremap : ;
" Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>
nnoremap <silent> zk O<Esc>
"Make cursor move as expected with wrapped lines:
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
"Map Shift+ J to previous buffer
noremap <S-J> :bp<CR>
"Map Shift + K to next buffer
noremap <S-k> :bn<CR>
"Turn on syntax (I guess)
syntax on
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
" set viminfo='10,\"100,:20,%,n~/.viminfo
"Restore cursor position
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Fast saving
noremap <leader>w :w!<cr>
" Fast editing of the .vimrc
" map <leader>e :e! ~/.vimrc<cr>
" noremap <leader>e :e! c:\\Users/username/.vimrc<cr>
" When vimrc is edited, reload it
" autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
"These two lines display the file name at the bottom
set modeline
set ls=2
"Default for checking marks is 4 seconds, make it faster
set updatetime=100
"Persistent Undo
" set undodir=~/.vim/undodir
set undodir=c:\\Users\user\vim\undodir
set undofile
set undolevels=10000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
"Keep undo history when switching buffers
set hidden
"Don't use vi-compatibility mode
set nocompatible
"Use the smart version of backspace (jumps over tabs apparently instead of
"spaces
set backspace=2
"Use spaces instead of tabs
set expandtab
"Line Numbers
set number
"Makes unnamed clipboard accesible to X window
set clipboard=unnamedplus
"Number of spaces to use for each step of (auto)indent.
set shiftwidth=4
"This shows what you are typing as a command
set showcmd
"Not too sure what this does
set smarttab
"Indent every time you press enter
set autoindent
set smartindent
"Use C style indent instead (note this causes problems with non C code)
" set cindent
"Cursor Always in middle
"NOTE This causes problems with word wrap of long lines as they are not
"displayed correctly
set scrolloff=999
"Always display row/column info
set ruler
"make word wrap wrap words, not character
set formatoptions=l
set lbr
"Use ... when word wrapping
set showbreak=...
"enable status line always
set laststatus=2
"
" statusline
" cf the default statusline: %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" format markers:
" %< truncation point
" %n buffer number
" %f relative path to file
" %m modified flag [+] (modified), [-] (unmodifiable) or nothing
" %r readonly flag [RO]
" %y filetype [ruby]
" %= split point for left and right justification
" %-35. width specification
" %l current line number
" %L number of lines in buffer
" %c current column number
" %V current virtual column number (-n), if different from %c
" %P percentage through buffer
" %) end of width specification
set statusline=%f%m%r%h%w[%n]\ [F=%{&ff}][T=%Y]\ %=[LINE=%l][%p%%]
"set it up to change the status line based on mode
if version >= 700
au InsertEnter * hi StatusLine term=reverse ctermbg=4
au InsertLeave * hi StatusLine term=reverse ctermbg=2
endif
"start searching as you type
set incsearch
"Map jj to escape
inoremap jj <Esc>
"Highlight search strings
set hlsearch
" Set off the other paren
highlight MatchParen ctermbg=4
"Ignore case when searching
set ignorecase
"But remember case when capitals used
set smartcase
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif
"Show matching brackets when text indicator is over them
set showmatch
"How many tenths of a second to blink
"Does not seem to change anything
set mat=2
"Highlight current line
set cul
"adjust highlight color
hi CursorLine term=none cterm=none ctermbg=232
"enable 256 color
set t_Co=256
"Do not want spell checking in my commented blocks
let g:tex_comment_nospell= 1
if &t_Co == 256
" colorscheme xoria256
colorscheme desert
else
colorscheme peachpuff
endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
function! Time()
return strftime("%c", getftime(bufname("%")))
endfunction
" Font size
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h14:cANSI
endif
endif
You have trailing whitespace in your command. (Actually a bunch of mappings have it)
Delete it.
The trailing whitespace is added to the command and moves the cursor forward equal to the number of spaces.
An easy way to do this on the whole file is to run
:%s/\s\+$//
What's the point of a comment like this one:
"Turn on syntax (I guess)
syntax on
or this one:
"Keep undo history when switching buffers
set hidden
or this one:
"Not too sure what this does
set smarttab
or this one:
"These two lines display the file name at the bottom
set modeline
set ls=2
(especially considering you enable the statusline a second time later)
Also…
"enable 256 color
set t_Co=256
if &t_Co == 256
colorscheme desert
else
colorscheme peachpuff
endif
Thanks to set t_Co=256 you will never see peachpuff.
set t_Co=256 has nothing to do in your vimrc. Set up your terminal emulator instead.
"Always display row/column info
set ruler
" statusline
set statusline=%f%m%r%h%w[%n]\ [F=%{&ff}][T=%Y]\ %=[LINE=%l][%p%%]
Your custom statusline overrides 'ruler'. Remove set ruler from your config.
set smartindent
is not "smart" at all. Remove it from your config.
"Don't use vi-compatibility mode
set nocompatible
is both wrong and useless. Remove it from your config.
"Turn on syntax (I guess)
syntax on
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
syntax on implies filetype on,
filetype plugin on implies filetype on,
you already did syntax on so there's no need to do syntax enable.
Use this instead:
filetype plugin indent on
syntax on
noremap <S-k> :bn<CR>
should be:
nnoremap K :bn<CR>
but K — keyword lookup — is rather useful so that's not a very good idea.
noremap <S-J> :bp<CR>
should be:
nnoremap J :bp<CR>
but J — join — is too useful to be remapped to anything.
let g:mapleader = ","
is useless and can be removed safely.
I'm really eager to include the following in my .vimrc file:
inoremap <Tab> <C-x><C-u>
If I set it within a buffer (via :inoremap <Tab> <C-x><C-u>) it works exactly as I'd hoped.
But, if I place it in my .vimrc, it doesn't seem to be acknowledged at all.
I've attached my .vimrc below. A few things:
Other changes to the .vimrc file are picked up, so it's not the wrong file
Have tried adding at the very bottom of the .vimrc & still doesn't work, so it's not being overwritten
Any ideas appreciated. Many thanks.
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Word complete
" :autocmd BufEnter * call DoWordComplete()
" let g:WC_min_len = 4
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
map j gj
map k gk
set showmatch " Show matching brackets
set mat=5 " Bracket blinking
set noerrorbells " No noise
" Ruby autocomplete
" Autocomplete behaviour
set completeopt=longest,menuone
open omni completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
" open user completion menu closing previous if open and opening new menu without changing the text
inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" highlight Pmenu ctermbg=238 gui=bold "improve autocomplete menu color
" Colours
highlight Pmenu ctermfg=6 ctermbg=238 guibg=grey30
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" if has("vms")
" set nobackup " do not keep a backup file, use versions instead
" else
" set backup " keep a backup file
" endif
" Set backupdir to tmp
" Do not let vim create <filename>~ backup files
set nobackup
" set nowritebackup
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Set tab to 2 spaces
set ts=2
set shiftwidth=2
" Ignore case
set ignorecase
set smartcase
" Menu autocomplete
set wildmode=longest,list
set wildmenu
" Call pathogen
call pathogen#infect()
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Turn syntax highlighting on (Added by John Bayne, 18/08/2012)
syntax on
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" My customisations
" No backup files
set nobackup
set nowritebackup
set noswapfile
" Whitespace identifier
:highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
:match ExtraWhitespace /\s\+$/
" Colour options
" color codeschool
" set guifont=Monaco:h12
" let g:NERDTreeWinPos = "right"
" set guioptions-=T " Removes top toolbar
" set guioptions-=r " Removes right hand scroll bar
" set go-=L " Removes left hand scroll bar
" autocmd User Rails let b:surround_{char2nr('-')} = "<% \r %>" " displays <% %> correctly
" :set cpoptions+=$ " puts a $ marker for the end of words/lines in cw/c$ commands
" Tab behaviour for ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
inoremap <Tab> <C-x><C-u>
In this case, :scriptnames, while useful, is not the best way to see where a mapping was last set.
:verbose map <tab>
is a lot more precise.
Maybe another script is overwriting it after your .vimrc is read.
You can use :scriptnames to see what files are read on startup.
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.