Nick Piepmeier avatar Nick Piepmeier committed 8a458b9

Disabled evil mode for emacs; updated hgignore to stop bothering me about eclim; some small changes around ctrl-p in vim; added plugin to keep track of case when s///-ing in vim.

Comments (0)

Files changed (24)

 (add-to-list 'load-path "~/.emacs.d/undo-tree")
 
 ;; Fire up Evil
-(add-to-list 'load-path "~/.emacs.d/evil")
-(require 'evil)
-(evil-mode 1)
+;;(add-to-list 'load-path "~/.emacs.d/evil")
+;;(require 'evil)
+;;(evil-mode 1)
 
 (setq x-select-enable-clipboard)
 *.pyc
 .*.swp
 vim/.netrwhist
+vim/eclim
 vim/plugin/perforce.vim
 vim/last-session.vim
 vim/google.vimrc

vim/eclim/autoload/eclim/common/largefile.vim

 
 " Script Settings {{{
 let s:file_size = g:EclimLargeFileSize * 1024 * 1024
-let s:events = [
-    \ 'BufRead', 'BufWinEnter', 'BufWinLeave',
-    \ 'CursorHold',
-    \ 'FileType',
-  \ ]
+let s:events = ['BufRead', 'CursorHold', 'FileType']
 " }}}
 
 function! eclim#common#largefile#InitSettings() " {{{
   let file = expand("<afile>")
   let size = getfsize(file)
   if size >= s:file_size || size == -2
-    let b:save_events = &eventignore
-    let b:save_undo = &undolevels
-    let &eventignore=join(s:events, ',')
-    setlocal noswapfile nowrap bufhidden=unload
-    autocmd eclim_largefile BufEnter <buffer> call <SID>ApplySettings()
-    autocmd eclim_largefile BufLeave <buffer> call <SID>RevertSettings()
+    if !exists('b:save_events')
+      let b:save_events = &eventignore
+      call s:ApplySettings()
+      setlocal noswapfile nowrap bufhidden=unload
+      autocmd eclim_largefile BufEnter,BufWinEnter <buffer> call <SID>ApplySettings()
+      autocmd eclim_largefile BufLeave,BufWinLeave <buffer> call <SID>RevertSettings()
+    endif
   endif
 endfunction " }}}
 
 function! s:ApplySettings() " {{{
-  set undolevels=-1
+  let &eventignore=join(s:events, ',')
   if !exists('b:largefile_notified')
     let b:largefile_notified = 1
-    call eclim#util#Echo('Note: Large file settings applied.')"
+    call eclim#util#Echo('Note: Large file settings applied.')
   endif
 endfunction " }}}
 
 function! s:RevertSettings() " {{{
-  let &undolevels=b:save_undo
-  let &eventignore=b:save_events
+  if exists('b:save_events')
+    let &eventignore=b:save_events
+  endif
 endfunction " }}}
 
 " vim:ft=vim:fdm=marker

vim/eclim/autoload/eclim/common/license.vim

 "
 " License:
 "
-" Copyright (C) 2005 - 2011  Eric Van Dewoestine
+" Copyright (C) 2005 - 2012  Eric Van Dewoestine
 "
 " This program is free software: you can redistribute it and/or modify
 " it under the terms of the GNU General Public License as published by
   call map(contents, "substitute(v:val, '${year}', s:year, 'g')")
 
   let author = eclim#project#util#GetProjectSetting('org.eclim.user.name')
-  if type(author) != 0 && author != ''
+  if type(author) == g:STRING_TYPE && author != ''
     call map(contents, "substitute(v:val, '${author}', author, 'g')")
   endif
 
   let email = eclim#project#util#GetProjectSetting('org.eclim.user.email')
-  if type(email) != 0 && email != ''
+  if type(email) == g:STRING_TYPE && email != ''
     call map(contents, "substitute(v:val, '${email}', email, 'g')")
   endif
   call map(contents, "substitute(v:val, '\\s\\+$', '', '')")

vim/eclim/autoload/eclim/display/signs.vim

   let g:EclimShowQuickfixSigns = 1
 endif
 
+if !exists("g:EclimShowLoclistSigns")
+  let g:EclimShowLoclistSigns = 1
+endif
+
 if !exists("g:EclimQuickfixSignText")
   let g:EclimQuickfixSignText = '> '
 endif
 
   let qflist = filter(g:EclimShowQuickfixSigns ? getqflist() : [],
     \ 'bufnr("%") == v:val.bufnr')
-  let loclist = filter(getloclist(0), 'bufnr("%") == v:val.bufnr')
+  let loclist = filter(g:EclimShowLoclistSigns ? getloclist(0) : [],
+    \ 'bufnr("%") == v:val.bufnr')
 
   for [list, marker, prefix] in [
       \ [qflist, g:EclimQuickfixSignText, 'qf_'],

vim/eclim/autoload/eclim/java/ant/complete.vim

 
     let completions = []
     let results = eclim#ExecuteEclim(command)
-    if type(results) != 3
+    if type(results) != g:LIST_TYPE
       return
     endif
 
     let command = substitute(command, '<file>', file, '')
 
     let targets = eclim#ExecuteEclim(command)
-    if type(targets) != 3
+    if type(targets) != g:LIST_TYPE
       return []
     endif
 

vim/eclim/autoload/eclim/java/ant/doc.vim

 "
 " License:
 "
-" Copyright (C) 2005 - 2009  Eric Van Dewoestine
+" Copyright (C) 2005 - 2012  Eric Van Dewoestine
 "
 " This program is free software: you can redistribute it and/or modify
 " it under the terms of the GNU General Public License as published by
 " }}}
 
 " Script Varables {{{
+let s:targets = 'http://ant.apache.org/manual/targets.html'
 let s:using = 'http://ant.apache.org/manual/using.html#<element>s'
-let s:conditions = 'http://ant.apache.org/manual/CoreTasks/conditions.html'
-let s:mappers = 'http://ant.apache.org/manual/CoreTypes/mapper.html'
+let s:conditions = 'http://ant.apache.org/manual/Tasks/conditions.html#<element>'
+let s:mappers = 'http://ant.apache.org/manual/Types/mapper.html'
 let s:paths = 'http://ant.apache.org/manual/using.html#path'
 let s:types =
-  \ 'http://ant.apache.org/manual/CoreTypes/<element>.html'
+  \ 'http://ant.apache.org/manual/Types/<element>.html'
 let s:selectors =
-  \ 'http://ant.apache.org/manual/CoreTypes/selectors.html#<element>select'
+  \ 'http://ant.apache.org/manual/Types/selectors.html#<element>select'
 let s:contrib_1 =
   \ 'http://ant-contrib.sourceforge.net/tasks/tasks/<element>.html'
 let s:contrib_2 =
   \ 'http://ant-contrib.sourceforge.net/tasks/tasks/<element>_task.html'
 let s:element_docs = {
     \  'project'           : s:using,
+    \  'target'            : s:targets,
     \  'and'               : s:conditions,
     \  'checksum'          : s:conditions,
     \  'checs'             : s:conditions,

vim/eclim/autoload/eclim/java/complete.vim

     let command = substitute(command, '<layout>', g:EclimJavaCompleteLayout, '')
 
     let completions = []
-    let results = eclim#ExecuteEclim(command)
-    if type(results) != 3
+    let response = eclim#ExecuteEclim(command)
+    if type(response) != g:DICT_TYPE
       return
     endif
 
+    if has_key(response, 'missingImport') &&
+     \ response.missingImport != ""
+      let classname = response.missingImport
+      let func = "eclim#java#complete#ImportThenComplete('" . classname  ."')"
+      call feedkeys("\<c-r>=" . func . "\<cr>", 'n')
+      " prevents supertab's completion chain from attempting the next
+      " completion in the chain.
+      return -1
+    endif
+
+    if has_key(response, 'error') && len(response.completions) == 0
+      call eclim#util#EchoError(response.error.message)
+      return -1
+    endif
+
     " if the word has a '.' in it (like package completion) then we need to
     " strip some off according to what is currently in the buffer.
     let prefix = substitute(getline('.'),
     " when completing imports, the completions include ending ';'
     let semicolon = getline('.') =~ '\%' . col('.') . 'c\s*;'
 
-    for result in results
+    for result in response.completions
       let word = result.completion
 
       " strip off prefix if necessary.
   endif
 endfunction " }}}
 
+" ImportThenComplete {{{
+" Called by CodeComplete when the completion depends on a missing import.
+function! eclim#java#complete#ImportThenComplete(classname)
+  if eclim#java#import#Import(a:classname)
+    call feedkeys("\<c-x>\<c-u>", 'tn')
+  endif
+  return ''
+endfunction " }}}
+
 " vim:ft=vim:fdm=marker

vim/eclim/autoload/eclim/java/hierarchy.vim

   let command = substitute(command, '<offset>', eclim#util#GetOffset(), '')
   let command = substitute(command, '<encoding>', eclim#util#GetEncoding(), '')
   let result = eclim#ExecuteEclim(command)
-  if type(result) != 4
+  if type(result) != g:DICT_TYPE
     return
   endif
 

vim/eclim/autoload/eclim/java/import.vim

 "
 " License:
 "
-" Copyright (C) 2005 - 2011  Eric Van Dewoestine
+" Copyright (C) 2005 - 2012  Eric Van Dewoestine
 "
 " This program is free software: you can redistribute it and/or modify
 " it under the terms of the GNU General Public License as published by
 let s:import_regex = '^\s*import\s\+\(static\s\+\)\?\(.\{-}\)\s*;\s*'
 " }}}
 
-" Import() {{{
+" Import([classname]) {{{
 " Import the element under the cursor.
-function! eclim#java#import#Import()
-  let classname = expand('<cword>')
+function! eclim#java#import#Import(...)
+  let classname = a:0 ? a:1 : expand('<cword>')
 
   if !eclim#project#util#IsCurrentFileInProject()
     return
 
   if class != '0' && eclim#java#import#InsertImports([class])
     call eclim#util#EchoInfo("Imported '" . class . "'.")
+    return 1
   endif
 endfunction " }}}
 

vim/eclim/autoload/eclim/java/search.vim

   endif
 
   let results = s:Search(a:type, argline)
-  if type(results) != 3
+  if type(results) != g:LIST_TYPE
     return
   endif
   if !empty(results)
     if a:type == 'java_search'
       call eclim#util#SetLocationList(eclim#util#ParseLocationEntries(results))
+      let locs = getloclist(0)
       " if only one result and it's for the current file, just jump to it.
       " note: on windows the expand result must be escaped
-      if len(results) == 1 && results[0].filename =~ escape(expand('%:p'), '\') . '|'
+      if len(results) == 1 && locs[0].bufnr == bufnr('%')
         if results[0].line != 1 && results[0].column != 1
           lfirst
         endif

vim/eclim/autoload/eclim/lang.vim

 
     let completions = []
     let results = eclim#ExecuteEclim(command)
-    if type(results) != 3
+    if type(results) != g:LIST_TYPE
       return
     endif
 
 
   let port = eclim#client#nailgun#GetNgPort(workspace)
   let results =  eclim#ExecuteEclim(search_cmd, port)
-  if type(results) != 3
+  if type(results) != g:LIST_TYPE
     return
   endif
 
   if !empty(results)
     call eclim#util#SetLocationList(eclim#util#ParseLocationEntries(results))
+    let locs = getloclist(0)
     " if only one result and it's for the current file, just jump to it.
     " note: on windows the expand result must be escaped
-    if len(results) == 1 && results[0].filename =~ escape(expand('%:p'), '\') . '|'
+    if len(results) == 1 && locs[0].bufnr == bufnr('%')
       if results[0].line != 1 && results[0].column != 1
         lfirst
       endif
           let file = fnamemodify(file, ':h') . '/' . prefix . fnamemodify(file, ':t')
           let tempfile = expand('%:p:h') . '/' . prefix . expand('%:t')
           if a:0 < 2 || a:2
+            let savepatchmode = &patchmode
+            set patchmode=
             exec 'silent noautocmd write! ' . escape(tempfile, ' ')
+            let &patchmode = savepatchmode
           endif
         endif
       else

vim/eclim/autoload/eclim/project/tree.vim

   call eclim#project#tree#ProjectTreeOpen(names, dirs)
 endfunction " }}}
 
-" ProjectTreeOpen(names, dirs, [title]) " {{{
-function! eclim#project#tree#ProjectTreeOpen(names, dirs, ...)
+function! eclim#project#tree#ProjectTreeToggle() " {{{
+  let title = s:GetTreeTitle()
+  let bufnum = bufnr(title)
+  let winnum = bufwinnr(title)
+  if bufnum == -1 || winnum == -1
+    call eclim#project#tree#ProjectTree()
+  else
+    exec winnum . 'winc w'
+    close
+    winc p
+  endif
+endfunction " }}}
+
+function! eclim#project#tree#ProjectTreeOpen(names, dirs, ...) " {{{
   let expandDir = ''
   if g:EclimProjectTreeExpandPathOnOpen
     let expandDir = substitute(expand('%:p:h'), '\', '/', 'g')
   setlocal nomodifiable
 endfunction " }}}
 
-" ProjectTreeClose() " {{{
-function! eclim#project#tree#ProjectTreeClose()
+function! eclim#project#tree#ProjectTreeClose() " {{{
   if exists('t:project_tree_name') || exists('t:project_tree_id')
     let winnr = bufwinnr(s:GetTreeTitle())
     if winnr != -1
   endif
 endfunction " }}}
 
-" Restore() " {{{
-function! eclim#project#tree#Restore()
+function! eclim#project#tree#Restore() " {{{
   if exists('t:project_tree_restoring')
     return
   endif
   endif
 endfunction " }}}
 
-" s:GetTreeTitle() {{{
-function! s:GetTreeTitle()
+function! s:GetTreeTitle() " {{{
   " support a custom name from an external plugin
   if exists('t:project_tree_name')
     return t:project_tree_name
   return g:EclimProjectTreeTitle . t:project_tree_id
 endfunction " }}}
 
-" s:GetSharedTreeBuffer(names) {{{
-function! s:GetSharedTreeBuffer(names)
+function! s:GetSharedTreeBuffer(names) " {{{
   let instance_names = join(a:names, '_')
   let instance_names = substitute(instance_names, '\W', '_', 'g')
   if g:EclimProjectTreeSharedInstance &&
   return -1
 endfunction " }}}
 
-" s:Mappings() " {{{
-function! s:Mappings()
+function! s:Mappings() " {{{
   nnoremap <buffer> <silent> E :call <SID>OpenFile('edit')<cr>
   nnoremap <buffer> <silent> S :call <SID>OpenFile('split')<cr>
   nnoremap <buffer> <silent> \| :call <SID>OpenFile('vsplit')<cr>
     \ :call eclim#help#BufferHelp(b:project_tree_help, 'horizontal', 10)<cr>
 endfunction " }}}
 
-" s:InfoLine() {{{
-function! s:InfoLine()
+function! s:InfoLine() " {{{
   setlocal modifiable
   let pos = getpos('.')
   if len(b:roots) == 1
   setlocal nomodifiable
 endfunction " }}}
 
-" s:PathEcho() {{{
-function! s:PathEcho()
+function! s:PathEcho() " {{{
   if mode() != 'n'
     return
   endif
   endif
 endfunction " }}}
 
-" s:OpenFile(action) " {{{
-function! s:OpenFile(action)
+function! s:OpenFile(action) " {{{
   let path = eclim#tree#GetPath()
   if path !~ '/$'
     if !filereadable(path)
   endif
 endfunction " }}}
 
-" s:OpenFileName() " {{{
-function! s:OpenFileName()
+function! s:OpenFileName() " {{{
   let path = eclim#tree#GetPath()
   if !isdirectory(path)
     let path = fnamemodify(path, ':h') . '/'
   endif
 endfunction " }}}
 
-" s:YankFileName() " {{{
-function! s:YankFileName()
+function! s:YankFileName() " {{{
   let path = eclim#tree#GetPath()
   let [@*, @+, @"] = [path, path, path]
   call eclim#util#Echo('Copied path to clipboard: ' . path)
 endfunction " }}}
 
-" ProjectTreeSettings() {{{
-function! eclim#project#tree#ProjectTreeSettings()
+function! eclim#project#tree#ProjectTreeSettings() " {{{
   for action in g:EclimProjectTreeActions
     call eclim#tree#RegisterFileAction(action.pattern, action.name,
       \ "call eclim#project#tree#OpenProjectFile('" .
   endtry
 endfunction " }}}
 
-" InjectLinkedResources(dir, contents) {{{
-function! eclim#project#tree#InjectLinkedResources(dir, contents)
+function! eclim#project#tree#InjectLinkedResources(dir, contents) " {{{
   let project = eclim#project#util#GetProject(a:dir)
   if len(project) == 0
     return

vim/eclim/autoload/eclim/project/util.vim

     for workspace in workspaces
       let results = eclim#ExecuteEclim(
         \ s:command_projects, eclim#client#nailgun#GetNgPort(workspace))
-      if type(results) != 3
+      if type(results) != g:LIST_TYPE
         continue
       endif
       for project in results

vim/eclim/autoload/eclim/python/search.vim

 
   if !empty(results)
     call eclim#util#SetLocationList(eclim#util#ParseLocationEntries(results))
-
+    let locs = getloclist(0)
     " if only one result and it's for the current file, just jump to it.
     " note: on windows the expand result must be escaped
-    if len(results) == 1 && results[0] =~ escape(expand('%:p'), '\') . '|'
+    if len(results) == 1 && locs[0].bufnr == bufnr('%')
       if results[0] !~ '|1 col 1|'
         lfirst
       endif

vim/eclim/autoload/eclim/util.vim

   if a:message != "0" && g:EclimLogLevel >= a:level
     exec "echohl " . a:highlight
     redraw
-    for line in split(a:message, '\n')
-      echom line
-    endfor
+    if mode() == 'n'
+      for line in split(a:message, '\n')
+        echom line
+      endfor
+    else
+      " if we aren't in normal mode then use regular 'echo' since echom
+      " messages won't be displayed while the current mode is displayed in
+      " vim's command line.
+      echo a:message . "\n"
+    endif
     echohl None
   endif
 endfunction " }}}

vim/eclim/autoload/eclim/xml/format.vim

 "
 " License:
 "
-" Copyright (C) 2005 - 2010  Eric Van Dewoestine
+" Copyright (C) 2005 - 2012  Eric Van Dewoestine
 "
 " This program is free software: you can redistribute it and/or modify
 " it under the terms of the GNU General Public License as published by
 function! eclim#xml#format#Format()
   " first save the file and validate to ensure no errors
   call eclim#util#ExecWithoutAutocmds('update')
-  call eclim#xml#validate#Validate('', 1)
+  call eclim#xml#validate#Validate(0, '!')
   if len(getloclist(0)) > 0
     call eclim#util#EchoError(
       \ 'File contains errors (:lopen), please correct before formatting.')

vim/eclim/ftplugin/htmljinja.vim

 " Options {{{
 
 if exists('b:jinja_line_statement_prefix')
-  " the }\<bs> is a gross hack to force reindenting of auto added closing line
-  " block statement since otherwise auto indent isn't evaluated after
-  " inserting it.
   let b:endwise_addition =
     \ '\=getline(line(".") - 1)=~"^\\s*' . b:jinja_line_statement_prefix . '" ? '.
-    \ '"' . b:jinja_line_statement_prefix . ' end" . submatch(0) . "}\<bs>" : ' .
+    \ '"' . b:jinja_line_statement_prefix . ' end" . submatch(0) : ' .
     \ '"{% end" . submatch(0) . " %}"'
 else
   let b:endwise_addition = '{% end& %}'

vim/eclim/ftplugin/xml.vim

 "
 " License:
 "
-" Copyright (C) 2005 - 2011  Eric Van Dewoestine
+" Copyright (C) 2005 - 2012  Eric Van Dewoestine
 "
 " This program is free software: you can redistribute it and/or modify
 " it under the terms of the GNU General Public License as published by
 if g:EclimXmlValidate
   augroup eclim_xml
     autocmd! BufWritePost <buffer>
-    autocmd BufWritePost <buffer> call eclim#xml#validate#Validate(1, '')
+    autocmd BufWritePost <buffer> call eclim#xml#validate#Validate(1, '!')
   augroup END
 endif
 

vim/eclim/indent/htmljinja.vim

     endif
     let g:HtmlJinjaIndentMidElements .= tag
   endfor
+
+  exec 'setlocal indentkeys+==end' . element[0]
 endfor
 
 " HtmlJinjaIndentAnythingSettings() {{{

vim/eclim/plugin/eclim.vim

 
 if !exists("g:EclimHome")
   " set at build/install time.
-  let g:EclimHome = '/usr/local/google/users/pieps/eclipse38/testing/plugins/org.eclim_1.7.4'
+  let g:EclimHome = '/usr/local/google/users/pieps/eclipse38/testing/plugins/org.eclim_1.7.6'
   if has('win32unix')
     let g:EclimHome = eclim#cygwin#CygwinPath(g:EclimHome)
   endif

vim/eclim/plugin/project.vim

 
 let g:EclimProjectTreeTitle = 'ProjectTree_'
 
-if !exists('g:EclimProjectTreeAutoOpen')
+if !exists('g:EclimProjectTreeAutoOpen') || exists('g:vimplugin_running')
   let g:EclimProjectTreeAutoOpen = 0
 endif
 
   command -nargs=*
     \ -complete=customlist,eclim#project#util#CommandCompleteProject
     \ ProjectTree :call eclim#project#tree#ProjectTree(<f-args>)
+  command -nargs=0 ProjectTreeToggle :call eclim#project#tree#ProjectTreeToggle()
   command -nargs=0 ProjectsTree
     \ :call eclim#project#tree#ProjectTree(eclim#project#util#GetProjectNames())
   command -nargs=1

vim/personal.vimrc

   set wildignorecase
 endif
 
+" Better autocompletion
+" Complete until unique prefix, then show menu
+set completeopt+=longest
+
 " Remap ` to '
 nnoremap ' `
 nnoremap ` '
 
 " For Conque to keep it updating
 let g:ConqueTerm_ReadUnfocused = 1
+
+" Make indendtation for go correct
+au BufRead,BufNewFile *.go set noet ts=4 sw=4

vim/plugin/keepcase.vim

+" Description: Replace one word with another, keeping case.
+" Author: Michael Geddes <vimmer at frog.wheelycreek.net>
+" Date: 13th Mar 2007.
+" Version: 2.0
+" Patched by Luc Hermitte, on 13th Mar 2007.
+
+" Usage: Using KeepCase or KeepCaseSameLen defined here, do a substitution like this:
+" %s/\u\<old_word\>/\=KeepCaseSameLen(submatch(0), 'new_word')/g
+" 
+" * KeepCase( original_word , new_word )  
+"   returns the new word maintaining case 
+"   simply uses heuristics to work out some different common situations
+"     given   NewWord
+"     Word   	--> Newword
+"     WORD    --> NEWWORD
+"     word    --> newword
+"     WoRd    --> NewWord
+"     woRd    --> newWord
+" 
+" * KeepCaseSameLen( original_word , new_word )    
+" 	Returns the new word maintaining case
+" 	  Keeps the case exactly the same letter-for-letter
+" 	  It does work if the words aren't the same length, as it truncates or
+" 	  just coppies the case of the word for the length of the original word.
+"
+" * :SubstituteCase#\ctoto\(Titi\)tata#\1Tutu#g
+"     totoTitiTata -> titiTutu
+"     TotoTitiTata -> TitiTutu
+"     tototititata -> tititutu
+"     tototitiTata -> titiTutu
+"     TototitiTata -> TitiTutu
+
+
+let s:keep_case_m1='^\u\l\+$'
+let s:keep_case_r1='^\(.\)\(.\+\)$'
+let s:keep_case_s1='\u\1\L\2'
+
+let s:keep_case_m2='^\u\+$'
+let s:keep_case_r2='^.\+$'
+let s:keep_case_s2='\U&'
+
+let s:keep_case_m3='^\l\+$'
+let s:keep_case_r3='^.\+$'
+let s:keep_case_s3='\L&'
+
+let s:keep_case_m4='^\u.\+$'
+let s:keep_case_r4='^.\+$'
+let s:keep_case_s4='\u&'
+
+let s:keep_case_m5='^\l.\+$'
+let s:keep_case_r5='^.\+$'
+let s:keep_case_s5='\l&'
+
+fun! KeepCase( oldword, newword)
+  let n=1
+  while n <=5
+	exe 'let mx = s:keep_case_m'.n
+	if a:oldword =~ mx
+	  exe 'let rx = s:keep_case_r'.n
+	  exe 'let sx = s:keep_case_s'.n
+	  return substitute(a:newword,rx,sx,'')
+	endif
+	let n += 1
+  endwhile
+  return a:newword
+endfun
+"echo KeepCase('test','FreDrick')
+"echo KeepCase('Test','FrEdRick')
+"echo KeepCase('teSt','FrEdrIck')
+"echo KeepCase('TeSt','FrEdrIck')
+"echo KeepCase('TEST','FredRick')
+
+fun! KeepCaseSameLen( oldword, newword)
+  let ret=''
+  let i=0
+  let len=strlen(a:oldword)
+  while i<len
+	if a:oldword[i] =~ '\u'
+	  let ret .= substitute(a:newword[i],'.','\u&','')
+	elseif a:oldword[i] =~ '\l'
+	  let ret .= substitute(a:newword[i],'.','\l&','')
+	else
+	  let ret .= a:newword[i]
+	endif
+	let i += 1
+  endwhile
+  let ret .= strpart(a:newword,i,strlen(a:newword))
+  return ret
+endfun
+
+" LH's additions (13th Mar 2007)
+function! s:SubstituteCase(repl_arg) range
+  let sep = a:repl_arg[0]
+  let args = split(a:repl_arg, sep)
+  " Main keepcase
+  let args[1] = '\=KeepCase(submatch(0), ' . "'" . args[1] . "')"
+  " Take care of back-references
+  let args[1] = substitute(args[1], '\\\(\d\+\)', "'.submatch(\\1).'", 'g')
+
+  let cmd = a:firstline . ',' . a:lastline . 's' . sep . join(args, sep)
+  exe cmd
+endfunction
+
+:command! -nargs=1 -range SubstituteCase 
+      \ <line1>,<line2>call s:SubstituteCase(<f-args>)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.