Clipboard fix + Search selection + Search cword fix
* Now use the correct clipboard register depending on whether unnamedplus is available * Added word boundaries to replace cword function from normal mode * Added replace selection mapping in visual mode * Copied VisualSelection() function from stack overflow (source link in code)
This commit is contained in:
parent
f627f0ca1a
commit
ebf84e7d34
1 changed files with 20 additions and 2 deletions
22
vimrc
22
vimrc
|
@ -81,7 +81,11 @@ set cmdheight=1
|
||||||
set timeoutlen=1200
|
set timeoutlen=1200
|
||||||
|
|
||||||
" Clipboard and Copy/Paste things
|
" Clipboard and Copy/Paste things
|
||||||
set clipboard=unnamed " Allow copying to and from OS clipboard
|
if has('unnamedplus') " Allow copying to and from OS clipboard
|
||||||
|
set clipboard=unnamedplus
|
||||||
|
else
|
||||||
|
set clipboard=unnamed
|
||||||
|
end
|
||||||
noremap <leader>d "_d
|
noremap <leader>d "_d
|
||||||
noremap <leader>d "_d
|
noremap <leader>d "_d
|
||||||
noremap x "_x
|
noremap x "_x
|
||||||
|
@ -121,6 +125,19 @@ function! QuickfixAddLine(filename, lnum, text)
|
||||||
call setqflist([{'filename': a:filename, 'lnum': a:lnum, 'desc': a:text}], 'a')
|
call setqflist([{'filename': a:filename, 'lnum': a:lnum, 'desc': a:text}], 'a')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" https://stackoverflow.com/a/6271254/4984564
|
||||||
|
function! VisualSelection()
|
||||||
|
let [line_start, column_start] = getpos("'<")[1:2]
|
||||||
|
let [line_end, column_end] = getpos("'>")[1:2]
|
||||||
|
let lines = getline(line_start, line_end)
|
||||||
|
if len(lines) == 0
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
let lines[-1] = lines[-1][: column_end - 2]
|
||||||
|
let lines[0] = lines[0][column_start - 1:]
|
||||||
|
return join(lines, "\n")
|
||||||
|
endfunction
|
||||||
|
|
||||||
" === GENERAL COMMANDS ===
|
" === GENERAL COMMANDS ===
|
||||||
command! L lopen | set number | set norelativenumber
|
command! L lopen | set number | set norelativenumber
|
||||||
command! LAddLine call LocationAddLine(expand("%"), line("."), getline("."))
|
command! LAddLine call LocationAddLine(expand("%"), line("."), getline("."))
|
||||||
|
@ -168,7 +185,8 @@ nnoremap <C-d> :copy .<CR>
|
||||||
nnoremap dx 0"_d$
|
nnoremap dx 0"_d$
|
||||||
nnoremap dcx 0d$
|
nnoremap dcx 0d$
|
||||||
nnoremap <leader>: :let @* = @:<CR>
|
nnoremap <leader>: :let @* = @:<CR>
|
||||||
nnoremap <expr> <S-r> ":%s/".expand("<cword>")."/"
|
nnoremap <expr> <S-r> ":%s/\\<".expand("<cword>")."\\>/"
|
||||||
|
vnoremap <expr> <S-r> "\<C-c>:redraw<CR>:%s/".VisualSelection()."/"
|
||||||
|
|
||||||
" Tabs vs. Spaces
|
" Tabs vs. Spaces
|
||||||
nnoremap <C-tab> :setl expandtab!<CR>:set expandtab?<CR>
|
nnoremap <C-tab> :setl expandtab!<CR>:set expandtab?<CR>
|
||||||
|
|
Loading…
Reference in a new issue