Rename stuff in vimrc
This commit is contained in:
parent
a529cd6560
commit
2a57ce8837
124
vimrc
124
vimrc
|
@ -26,12 +26,12 @@ let s:uname = system("echo -n \"$(uname)\"")
|
||||||
let g:vim_dir = $HOME . "/.vim"
|
let g:vim_dir = $HOME . "/.vim"
|
||||||
let mapleader=","
|
let mapleader=","
|
||||||
|
|
||||||
function! IsWindows()
|
fu! IsWindows()
|
||||||
if s:uname =~ "mingw" || s:uname =~ "msys"
|
if s:uname =~ "mingw" || s:uname =~ "msys"
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
if has('termguicolors')
|
if has('termguicolors')
|
||||||
set termguicolors
|
set termguicolors
|
||||||
|
@ -40,12 +40,12 @@ if has('termguicolors')
|
||||||
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! PrintError(msg) abort
|
fu! PrintError(msg) abort
|
||||||
exec 'normal! \<Esc>'
|
exec 'normal! \<Esc>'
|
||||||
echohl ErrorMsg
|
echohl ErrorMsg
|
||||||
echomsg a:msg
|
echomsg a:msg
|
||||||
echohl None
|
echohl None
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
|
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
|
@ -193,13 +193,13 @@ let g:campo_custom_ctags_args = ""
|
||||||
" call g:SetExtraCtagsPaths([g:campo_jai_path.'/tags'])
|
" call g:SetExtraCtagsPaths([g:campo_jai_path.'/tags'])
|
||||||
"
|
"
|
||||||
" You can see what your ctags search list is set to in the editor with :echo &tags
|
" You can see what your ctags search list is set to in the editor with :echo &tags
|
||||||
function! g:SetExtraCtagsPaths(paths_array)
|
fu! g:SetExtraCtagsPaths(paths_array)
|
||||||
let l:list = './tags,tags' " This is the default tags list set by vim.
|
let l:list = './tags,tags' " This is the default tags list set by vim.
|
||||||
for path in a:paths_array
|
for path in a:paths_array
|
||||||
let l:list .= ',' . path
|
let l:list .= ',' . path
|
||||||
endfor
|
endfor
|
||||||
let &tags=l:list
|
let &tags=l:list
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
|
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
|
@ -475,7 +475,7 @@ augroup campoCmds
|
||||||
autocmd BufWritePost ~/.vimrc_templates.private silent! source $MYVIMRC
|
autocmd BufWritePost ~/.vimrc_templates.private silent! source $MYVIMRC
|
||||||
|
|
||||||
" Remove trailing whitespace when saving any file.
|
" Remove trailing whitespace when saving any file.
|
||||||
function! StripTrailingWhitespaces()
|
fu! StripTrailingWhitespaces()
|
||||||
if g:campo_strip_trailing_whitespace == 1
|
if g:campo_strip_trailing_whitespace == 1
|
||||||
if len(g:campo_directories_to_ignore_when_stripping_trailing_whitespace)
|
if len(g:campo_directories_to_ignore_when_stripping_trailing_whitespace)
|
||||||
for path in g:campo_directories_to_ignore_when_stripping_trailing_whitespace
|
for path in g:campo_directories_to_ignore_when_stripping_trailing_whitespace
|
||||||
|
@ -671,7 +671,7 @@ nnoremap <c-g> :%s///g<left><left>
|
||||||
" order to only call it once for a group of saves I've had to remap the
|
" order to only call it once for a group of saves I've had to remap the
|
||||||
" various save commands to a function call.
|
" various save commands to a function call.
|
||||||
|
|
||||||
function! CreateCtags()
|
fu! CreateCtags()
|
||||||
" Only allow one instance of ctags to run in this directory at any given time.
|
" Only allow one instance of ctags to run in this directory at any given time.
|
||||||
let l:lock_file = "ctags.lock"
|
let l:lock_file = "ctags.lock"
|
||||||
if filereadable(l:lock_file) || filereadable("newtags")
|
if filereadable(l:lock_file) || filereadable("newtags")
|
||||||
|
@ -725,32 +725,32 @@ endfun
|
||||||
" These write functions below will not be reloaded because they initiate the
|
" These write functions below will not be reloaded because they initiate the
|
||||||
" save. So if you make changes to them then you need to manually reload this
|
" save. So if you make changes to them then you need to manually reload this
|
||||||
" file using <leader>rv or whatever. :ReloadVimrcError
|
" file using <leader>rv or whatever. :ReloadVimrcError
|
||||||
function! WriteCurrentFileAndCreateCtags()
|
fu! WriteCurrentFileAndCreateCtags()
|
||||||
write!
|
write!
|
||||||
call CreateCtags()
|
call CreateCtags()
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! WriteCurrentFileAndCreateCtagsThenQuit()
|
fu! WriteCurrentFileAndCreateCtagsThenQuit()
|
||||||
write!
|
write!
|
||||||
call CreateCtags()
|
call CreateCtags()
|
||||||
quit
|
quit
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
" @fixme Sometimes a :wa that saves multiple files causes vim to hang and use a lot of CPU.
|
" @fixme Sometimes a :wa that saves multiple files causes vim to hang and use a lot of CPU.
|
||||||
function! WriteAllModifiedFilesAndCreateCtags()
|
fu! WriteAllModifiedFilesAndCreateCtags()
|
||||||
wall!
|
wall!
|
||||||
call CreateCtags()
|
call CreateCtags()
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
" Create a command abbreviation that only applies when it's at the beginning
|
" Create a command abbreviation that only applies when it's at the beginning
|
||||||
" of a ex command. If you were to do a normal cnoreabbrev or cabbrev then the
|
" of a ex command. If you were to do a normal cnoreabbrev or cabbrev then the
|
||||||
" subsitution can happen anywhere in the command line. It was mostly affecting
|
" subsitution can happen anywhere in the command line. It was mostly affecting
|
||||||
" my text search; I'd type '/w' and it would be replaced with the call to save
|
" my text search; I'd type '/w' and it would be replaced with the call to save
|
||||||
" and create ctags.
|
" and create ctags.
|
||||||
function! Cabbrev(key, value)
|
fu! Cabbrev(key, value)
|
||||||
exe printf('cabbrev <expr> %s (getcmdtype() == ":" && getcmdpos() <= %d) ? %s : %s',
|
exe printf('cabbrev <expr> %s (getcmdtype() == ":" && getcmdpos() <= %d) ? %s : %s',
|
||||||
\ a:key, len(a:key)+1, string(a:value), string(a:key))
|
\ a:key, len(a:key)+1, string(a:value), string(a:key))
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
call Cabbrev('w', 'call WriteCurrentFileAndCreateCtags()')
|
call Cabbrev('w', 'call WriteCurrentFileAndCreateCtags()')
|
||||||
call Cabbrev('W', 'call WriteCurrentFileAndCreateCtags()')
|
call Cabbrev('W', 'call WriteCurrentFileAndCreateCtags()')
|
||||||
|
@ -774,14 +774,14 @@ noremap Q <Nop>
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
" MULTIPURPOSE TAB KEY
|
" MULTIPURPOSE TAB KEY
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
function! InsertTabWrapper()
|
fu! InsertTabWrapper()
|
||||||
let l:col = col('.') - 1
|
let l:col = col('.') - 1
|
||||||
if !l:col || getline('.')[l:col - 1] !~ '\k'
|
if !l:col || getline('.')[l:col - 1] !~ '\k'
|
||||||
return "\<tab>"
|
return "\<tab>"
|
||||||
else
|
else
|
||||||
return "\<c-p>"
|
return "\<c-p>"
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
|
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
|
||||||
inoremap <s-tab> <c-n>
|
inoremap <s-tab> <c-n>
|
||||||
|
|
||||||
|
@ -883,12 +883,12 @@ let g:rg_window_height = g:quickfix_pane_height
|
||||||
" window and cmdline events but wasn't able to find anything that fired AFTER
|
" window and cmdline events but wasn't able to find anything that fired AFTER
|
||||||
" the tag command. So we're instead just setting the tags list once for the
|
" the tag command. So we're instead just setting the tags list once for the
|
||||||
" session and not bothering with changing it on the fly. See g:SetExtraCtagsPaths
|
" session and not bothering with changing it on the fly. See g:SetExtraCtagsPaths
|
||||||
function! CtrlP_Search(search_path)
|
fu! CtrlP_Search(search_path)
|
||||||
" If a:search_path is empty then ctrlp will use g:ctrlp_working_path_mode to determine the cwd to search in.
|
" If a:search_path is empty then ctrlp will use g:ctrlp_working_path_mode to determine the cwd to search in.
|
||||||
execute 'CtrlP ' . a:search_path
|
execute 'CtrlP ' . a:search_path
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! CtrlP_JaiSearch(jai_rel_search_path)
|
fu! CtrlP_JaiSearch(jai_rel_search_path)
|
||||||
if g:campo_jai_path == ''
|
if g:campo_jai_path == ''
|
||||||
call PrintError("g:campo_jai_path isn't set!")
|
call PrintError("g:campo_jai_path isn't set!")
|
||||||
return
|
return
|
||||||
|
@ -902,7 +902,7 @@ function! CtrlP_JaiSearch(jai_rel_search_path)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call CtrlP_Search(l:path)
|
call CtrlP_Search(l:path)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
" CtrlP File Searching
|
" CtrlP File Searching
|
||||||
noremap <leader>g :call CtrlP_Search('')<cr> " Search in current directory
|
noremap <leader>g :call CtrlP_Search('')<cr> " Search in current directory
|
||||||
|
@ -952,7 +952,7 @@ let s:light_rainbow = ['red', 'green', 'magenta', 'cyan', 'yellow', 'white', 'gr
|
||||||
let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray']
|
let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray']
|
||||||
let s:rainbow_theme = g:campo_light_dark_mode
|
let s:rainbow_theme = g:campo_light_dark_mode
|
||||||
|
|
||||||
function! UpdateRainbowConf()
|
fu! UpdateRainbowConf()
|
||||||
let g:rainbow_conf = {
|
let g:rainbow_conf = {
|
||||||
\ 'ctermfgs': (s:rainbow_theme == "light"? s:dark_rainbow : s:light_rainbow)
|
\ 'ctermfgs': (s:rainbow_theme == "light"? s:dark_rainbow : s:light_rainbow)
|
||||||
\}
|
\}
|
||||||
|
@ -960,11 +960,11 @@ function! UpdateRainbowConf()
|
||||||
"\ '*': 0, " Disable all
|
"\ '*': 0, " Disable all
|
||||||
"\ 'c++': {} " Only enable c++
|
"\ 'c++': {} " Only enable c++
|
||||||
"\ }
|
"\ }
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
call UpdateRainbowConf()
|
call UpdateRainbowConf()
|
||||||
|
|
||||||
function! ReloadRainbow()
|
fu! ReloadRainbow()
|
||||||
if g:campo_theme_use_rainbow_parens
|
if g:campo_theme_use_rainbow_parens
|
||||||
if exists(':RainbowToggle')
|
if exists(':RainbowToggle')
|
||||||
call UpdateRainbowConf()
|
call UpdateRainbowConf()
|
||||||
|
@ -977,7 +977,7 @@ function! ReloadRainbow()
|
||||||
call rainbow#clear()
|
call rainbow#clear()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
|
|
||||||
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
|
@ -999,15 +999,15 @@ noremap <leader>l :call ToggleLightDarkTheme()<cr>
|
||||||
|
|
||||||
let s:current_light_dark_mode = g:campo_light_dark_mode
|
let s:current_light_dark_mode = g:campo_light_dark_mode
|
||||||
|
|
||||||
function! ToggleLightDarkTheme()
|
fu! ToggleLightDarkTheme()
|
||||||
if s:current_light_dark_mode == 'light'
|
if s:current_light_dark_mode == 'light'
|
||||||
call ChangeLightDarkMode('dark', 0)
|
call ChangeLightDarkMode('dark', 0)
|
||||||
else
|
else
|
||||||
call ChangeLightDarkMode('light', 0)
|
call ChangeLightDarkMode('light', 0)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! ChangeLightDarkMode(mode, onlySetTheme)
|
fu! ChangeLightDarkMode(mode, onlySetTheme)
|
||||||
if a:mode == 'light'
|
if a:mode == 'light'
|
||||||
let s:rainbow_theme = 'light'
|
let s:rainbow_theme = 'light'
|
||||||
let s:theme = g:campo_light_theme
|
let s:theme = g:campo_light_theme
|
||||||
|
@ -1028,7 +1028,7 @@ function! ChangeLightDarkMode(mode, onlySetTheme)
|
||||||
if !a:onlySetTheme
|
if !a:onlySetTheme
|
||||||
exec 'AirlineTheme' a:mode
|
exec 'AirlineTheme' a:mode
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
" Set the intial light/dark mode.
|
" Set the intial light/dark mode.
|
||||||
if g:campo_light_dark_mode =~ 'light'
|
if g:campo_light_dark_mode =~ 'light'
|
||||||
|
@ -1038,14 +1038,14 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Open the current color scheme for editing.
|
" Open the current color scheme for editing.
|
||||||
function! EditColorScheme()
|
fu! EditColorScheme()
|
||||||
let l:path = g:vim_dir . '/colors/' . s:theme . '.vim'
|
let l:path = g:vim_dir . '/colors/' . s:theme . '.vim'
|
||||||
if filereadable(l:path)
|
if filereadable(l:path)
|
||||||
execute 'vsplit ' . l:path
|
execute 'vsplit ' . l:path
|
||||||
else
|
else
|
||||||
call PrintError("Failed to open " . l:path . " for editing.")
|
call PrintError("Failed to open " . l:path . " for editing.")
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
command -nargs=0 EditColorScheme call EditColorScheme()
|
command -nargs=0 EditColorScheme call EditColorScheme()
|
||||||
|
|
||||||
|
@ -1129,10 +1129,10 @@ let errormarker_warninggroup = "BuildWarn"
|
||||||
let errormarker_infogroup = "BuildInfo"
|
let errormarker_infogroup = "BuildInfo"
|
||||||
|
|
||||||
" I don't know how to map to a plugin command, so I'm wrapping it with a function...ugh.
|
" I don't know how to map to a plugin command, so I'm wrapping it with a function...ugh.
|
||||||
function! ShowErrorAtCursor()
|
fu! ShowErrorAtCursor()
|
||||||
" This is defined in errormarker.vim
|
" This is defined in errormarker.vim
|
||||||
ErrorAtCursor
|
ErrorAtCursor
|
||||||
endfunction
|
endfu
|
||||||
nnoremap <leader>ce :call ShowErrorAtCursor()<cr>
|
nnoremap <leader>ce :call ShowErrorAtCursor()<cr>
|
||||||
|
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
|
@ -1143,7 +1143,7 @@ nnoremap <leader>ce :call ShowErrorAtCursor()<cr>
|
||||||
" This will print the valid entries. You'll know parsing is correct when the
|
" This will print the valid entries. You'll know parsing is correct when the
|
||||||
" entries have a type, line num, error message, etc.
|
" entries have a type, line num, error message, etc.
|
||||||
|
|
||||||
function! ShowErrorEntries()
|
fu! ShowErrorEntries()
|
||||||
" Prints out valid quickfix errors.
|
" Prints out valid quickfix errors.
|
||||||
redraw!
|
redraw!
|
||||||
for l:d in getqflist()
|
for l:d in getqflist()
|
||||||
|
@ -1151,7 +1151,7 @@ function! ShowErrorEntries()
|
||||||
echomsg l:d
|
echomsg l:d
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfu
|
||||||
command -nargs=0 ShowErrorEntries call ShowErrorEntries()
|
command -nargs=0 ShowErrorEntries call ShowErrorEntries()
|
||||||
|
|
||||||
" Jai
|
" Jai
|
||||||
|
@ -1185,25 +1185,25 @@ set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m
|
||||||
" BUILD FUNCTIONS
|
" BUILD FUNCTIONS
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
|
|
||||||
function! HideBuildResultsAndClearErrors()
|
fu! HideBuildResultsAndClearErrors()
|
||||||
RemoveErrorMarkers
|
RemoveErrorMarkers
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_pane_height, 0)
|
call asyncrun#quickfix_toggle(g:quickfix_pane_height, 0)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! HideAsyncResults()
|
fu! HideAsyncResults()
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_pane_height, 0)
|
call asyncrun#quickfix_toggle(g:quickfix_pane_height, 0)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! ToggleBuildResults()
|
fu! ToggleBuildResults()
|
||||||
call asyncrun#quickfix_toggle(g:quickfix_pane_height)
|
call asyncrun#quickfix_toggle(g:quickfix_pane_height)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! StopRunTask()
|
fu! StopRunTask()
|
||||||
AsyncStop
|
AsyncStop
|
||||||
call HideAsyncResults()
|
call HideAsyncResults()
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! Build(optimized=0, silent=0)
|
fu! Build(optimized=0, silent=0)
|
||||||
let l:async_cmd = "AsyncRun! "
|
let l:async_cmd = "AsyncRun! "
|
||||||
if a:silent
|
if a:silent
|
||||||
let l:async_cmd .= "-post=call\\ HideAsyncResults() "
|
let l:async_cmd .= "-post=call\\ HideAsyncResults() "
|
||||||
|
@ -1290,9 +1290,9 @@ function! Build(optimized=0, silent=0)
|
||||||
" be generated so we're handling the save ourselves.
|
" be generated so we're handling the save ourselves.
|
||||||
call WriteAllModifiedFilesAndCreateCtags()
|
call WriteAllModifiedFilesAndCreateCtags()
|
||||||
exec l:async_cmd . l:cmd
|
exec l:async_cmd . l:cmd
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! RunProgram()
|
fu! RunProgram()
|
||||||
let l:ran = 0
|
let l:ran = 0
|
||||||
let l:ext = tolower(expand('%:e'))
|
let l:ext = tolower(expand('%:e'))
|
||||||
let l:path_to_use = ""
|
let l:path_to_use = ""
|
||||||
|
@ -1352,7 +1352,7 @@ function! RunProgram()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
" Show results window the moment the async job starts
|
" Show results window the moment the async job starts
|
||||||
augroup asyncPluginCmds
|
augroup asyncPluginCmds
|
||||||
|
@ -1394,7 +1394,7 @@ nnoremap <C-p> :cp<CR>
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
|
|
||||||
" Search using ripgrep (first install with Rust: cargo install ripgrep).
|
" Search using ripgrep (first install with Rust: cargo install ripgrep).
|
||||||
function! Search(path, search_args, case_insensitive=0)
|
fu! Search(path, search_args, case_insensitive=0)
|
||||||
let l:helper = "Search '" . a:path . "' (" . (len(a:search_args) > 0 ? a:search_args . " | " : '') . (a:case_insensitive ? "INSENSITIVE" : "SENSITIVE") . "): "
|
let l:helper = "Search '" . a:path . "' (" . (len(a:search_args) > 0 ? a:search_args . " | " : '') . (a:case_insensitive ? "INSENSITIVE" : "SENSITIVE") . "): "
|
||||||
let l:term = input(l:helper)
|
let l:term = input(l:helper)
|
||||||
if empty(l:term)
|
if empty(l:term)
|
||||||
|
@ -1415,9 +1415,9 @@ function! Search(path, search_args, case_insensitive=0)
|
||||||
let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
|
let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
|
||||||
let l:cmd = printf(l:format, shellescape(l:escaped_term))
|
let l:cmd = printf(l:format, shellescape(l:escaped_term))
|
||||||
exec l:cmd
|
exec l:cmd
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! SearchExt(path, search_args, case_insensitive=0)
|
fu! SearchExt(path, search_args, case_insensitive=0)
|
||||||
call inputsave()
|
call inputsave()
|
||||||
let l:ext = input('Enter extension to search on (leave blank for files with no ext): ')
|
let l:ext = input('Enter extension to search on (leave blank for files with no ext): ')
|
||||||
call inputrestore()
|
call inputrestore()
|
||||||
|
@ -1432,7 +1432,7 @@ function! SearchExt(path, search_args, case_insensitive=0)
|
||||||
let l:args = a:search_args." -g \"".l:ext."\""
|
let l:args = a:search_args." -g \"".l:ext."\""
|
||||||
|
|
||||||
call Search(a:path, l:args, a:case_insensitive)
|
call Search(a:path, l:args, a:case_insensitive)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
" SEARCH IN CURRENT WORKING DIRECTORY
|
" SEARCH IN CURRENT WORKING DIRECTORY
|
||||||
|
@ -1508,7 +1508,7 @@ nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
|
||||||
|
|
||||||
" Replace text in a git repo's committed files.
|
" Replace text in a git repo's committed files.
|
||||||
" The range identifier allows us to run this once when multiple lines are selected in a file.
|
" The range identifier allows us to run this once when multiple lines are selected in a file.
|
||||||
function! GlobalReplaceIt(confirm_replacement) range
|
fu! GlobalReplaceIt(confirm_replacement) range
|
||||||
if exists(':Ggrep')
|
if exists(':Ggrep')
|
||||||
call inputsave()
|
call inputsave()
|
||||||
if a:confirm_replacement
|
if a:confirm_replacement
|
||||||
|
@ -1561,7 +1561,7 @@ function! GlobalReplaceIt(confirm_replacement) range
|
||||||
else
|
else
|
||||||
call PrintError("Unable to search since you're not in a git repo!")
|
call PrintError("Unable to search since you're not in a git repo!")
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
noremap <leader>r :call GlobalReplaceIt(0)<cr>
|
noremap <leader>r :call GlobalReplaceIt(0)<cr>
|
||||||
noremap <leader>rr :call GlobalReplaceIt(1)<cr>
|
noremap <leader>rr :call GlobalReplaceIt(1)<cr>
|
||||||
|
|
||||||
|
@ -1570,7 +1570,7 @@ noremap <leader>rr :call GlobalReplaceIt(1)<cr>
|
||||||
" RENAME CURRENT FILE
|
" RENAME CURRENT FILE
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
|
|
||||||
function! RenameFile()
|
fu! RenameFile()
|
||||||
let l:old_name = expand('%')
|
let l:old_name = expand('%')
|
||||||
let l:new_name = input('New file name: ', expand('%'), 'file')
|
let l:new_name = input('New file name: ', expand('%'), 'file')
|
||||||
if l:new_name != '' && l:new_name != l:old_name
|
if l:new_name != '' && l:new_name != l:old_name
|
||||||
|
@ -1581,7 +1581,7 @@ function! RenameFile()
|
||||||
redraw!
|
redraw!
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
noremap <leader>n :call RenameFile()<cr>
|
noremap <leader>n :call RenameFile()<cr>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1589,19 +1589,19 @@ noremap <leader>n :call RenameFile()<cr>
|
||||||
" CENTER THE BUFFER
|
" CENTER THE BUFFER
|
||||||
"##################################################################################
|
"##################################################################################
|
||||||
|
|
||||||
function! CenterPane()
|
fu! CenterPane()
|
||||||
" Centers the current pane as the middle 2 of 4 imaginary columns should
|
" Centers the current pane as the middle 2 of 4 imaginary columns should
|
||||||
" be called in a window with a single pane.
|
" be called in a window with a single pane.
|
||||||
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
" Taken from https://dev.to/vinneycavallo/easily-center-content-in-vim
|
||||||
lefta vnew
|
lefta vnew
|
||||||
wincmd w
|
wincmd w
|
||||||
exec 'vertical resize' string(&columns * 0.65)
|
exec 'vertical resize' string(&columns * 0.65)
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
function! RemoveCenterPane()
|
fu! RemoveCenterPane()
|
||||||
wincmd w
|
wincmd w
|
||||||
close
|
close
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
nnoremap <leader>cc :call CenterPane()<cr>
|
nnoremap <leader>cc :call CenterPane()<cr>
|
||||||
nnoremap <leader>cd :call RemoveCenterPane()<cr>
|
nnoremap <leader>cd :call RemoveCenterPane()<cr>
|
||||||
|
@ -1614,7 +1614,7 @@ nnoremap <leader>cd :call RemoveCenterPane()<cr>
|
||||||
" Applies a clean view of the current buffer by turning off line
|
" Applies a clean view of the current buffer by turning off line
|
||||||
" numbers, trailing spaces, tabs and git diff markers in the gutter.
|
" numbers, trailing spaces, tabs and git diff markers in the gutter.
|
||||||
|
|
||||||
function! ToggleSimpleView()
|
fu! ToggleSimpleView()
|
||||||
" I wasn't able to get this to apply to every copy of the same buffer,
|
" I wasn't able to get this to apply to every copy of the same buffer,
|
||||||
" e.g. you have a split view showing the same file; only the active one
|
" e.g. you have a split view showing the same file; only the active one
|
||||||
" will be affected, but they will share the same state! I tried many
|
" will be affected, but they will share the same state! I tried many
|
||||||
|
@ -1640,7 +1640,7 @@ function! ToggleSimpleView()
|
||||||
setlocal list
|
setlocal list
|
||||||
exec 'GitGutterBufferEnable'
|
exec 'GitGutterBufferEnable'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfu
|
||||||
|
|
||||||
nnoremap <leader>c :call ToggleSimpleView()<cr>
|
nnoremap <leader>c :call ToggleSimpleView()<cr>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user