fix encoding when yanking to windows in vim
This commit is contained in:
parent
bf585170ac
commit
352ff322e1
41
.vimrc
41
.vimrc
@ -18,6 +18,10 @@ Plugin 'pearofducks/ansible-vim'
|
|||||||
Plugin 'mechatroner/rainbow_csv'
|
Plugin 'mechatroner/rainbow_csv'
|
||||||
" ChatGPT plugin
|
" ChatGPT plugin
|
||||||
Plugin 'CamdenClark/flyboy'
|
Plugin 'CamdenClark/flyboy'
|
||||||
|
" Aider
|
||||||
|
Plugin 'joshuavial/aider.nvim'
|
||||||
|
" Black
|
||||||
|
Plugin 'psf/black'
|
||||||
" All of your Plugins must be added before the following line
|
" All of your Plugins must be added before the following line
|
||||||
call vundle#end() " required
|
call vundle#end() " required
|
||||||
filetype plugin indent on " required
|
filetype plugin indent on " required
|
||||||
@ -72,13 +76,37 @@ set statusline +=%2*0x%04B\ %* "character under cursor
|
|||||||
" Copy to clipboard
|
" Copy to clipboard
|
||||||
" set clipboard=unnamedplus
|
" set clipboard=unnamedplus
|
||||||
|
|
||||||
if system('uname -r') =~ "Microsoft"
|
"if system('uname -r') =~ "Microsoft"
|
||||||
augroup Yank
|
" augroup Yank
|
||||||
autocmd!
|
" autocmd!
|
||||||
autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@")
|
" autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@")
|
||||||
augroup END
|
" augroup END
|
||||||
|
"endif
|
||||||
|
|
||||||
|
" only on WSL
|
||||||
|
if has('unix') && system('uname -r') =~ 'Microsoft'
|
||||||
|
|
||||||
|
augroup YankToWindowsClipboard
|
||||||
|
autocmd!
|
||||||
|
autocmd TextYankPost * call s:WslYank()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
function! s:WslYank() abort
|
||||||
|
" get the yanked text
|
||||||
|
let l:txt = @"
|
||||||
|
" shell-escape it
|
||||||
|
let l:esc = shellescape(l:txt)
|
||||||
|
" pipe through iconv to UTF-16LE, then into clip.exe
|
||||||
|
call system(
|
||||||
|
\ 'printf %s '.l:esc.
|
||||||
|
\ ' | iconv -f utf-8 -t utf-16le'.
|
||||||
|
\ ' | /mnt/c/Windows/System32/clip.exe'
|
||||||
|
\ )
|
||||||
|
endfunction
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
"map <silent> "=p :r !powershell.exe -Command Get-Clipboard<CR>
|
"map <silent> "=p :r !powershell.exe -Command Get-Clipboard<CR>
|
||||||
"map! <silent> <C-r>= :r !powershell.exe -Command Get-Clipboard<CR>
|
"map! <silent> <C-r>= :r !powershell.exe -Command Get-Clipboard<CR>
|
||||||
"noremap "+p :exe 'norm a'.system('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Get-Clipboard')<CR>
|
"noremap "+p :exe 'norm a'.system('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Get-Clipboard')<CR>
|
||||||
@ -108,7 +136,8 @@ endif
|
|||||||
" generate pw?
|
" generate pw?
|
||||||
" r! cmd.exe /c 'python C:\Tools\pw.py 10'
|
" r! cmd.exe /c 'python C:\Tools\pw.py 10'
|
||||||
" =system("cmd.exe /c 'python C:\\Tools\\pw.py 10' | tr -d '\n' | tr -d '\r'")
|
" =system("cmd.exe /c 'python C:\\Tools\\pw.py 10' | tr -d '\n' | tr -d '\r'")
|
||||||
let pwcmd = 'cmd.exe /c "python C:\\Tools\\pw.py 10" |tr -d "\\n"|tr -d "\\r"'
|
"let pwcmd = 'cmd.exe /c "python C:\\Tools\\pw.py 10" |tr -d "\\n"|tr -d "\\r"'
|
||||||
|
let pwcmd = 'powershell.exe -command "python C:\\Tools\\pw.py 10" |tr -d "\\n"|tr -d "\\r"'
|
||||||
:nmap <F8> "=system(pwcmd)<C-M>p
|
:nmap <F8> "=system(pwcmd)<C-M>p
|
||||||
:imap <F8> <C-R>=system(pwcmd)<C-M>
|
:imap <F8> <C-R>=system(pwcmd)<C-M>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user