cac*_*ein 7 neovim windows-subsystem-for-linux wsl-2
我在 wsl 中使用回形针时遇到问题,当使用 neovim 按 yy 复制一行时,我只能将其粘贴到 neovim 中,但我想要做的是将其粘贴到页面或 txt 文件中,而不会出现任何复杂情况在带有记事本的Windows中,这只是一个示例,我还希望能够从Windows复制并直接在neovim中使用字母p粘贴,然后才能使用相同的先前配置文件执行此操作,但是我必须格式化我的窗户被病毒感染了。
这是我的配置文件:
"set directory
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
"files
so ~\.config/nvim/.vim/plugins.vim
so ~\.config/nvim/.vim/plugin-config.vim
so ~\.config/nvim/.vim/maps.vim
set list
syntax enable
"show line number and relative number
set nu
set rnu
set numberwidth=1 "better show the numbers
"copy and paste with the mouse
set mouse=a
"enable copy and paste 'yy, p'
set clipboard=unnamed
"shows the pressed
set showcmd
"Show current column
set ruler
"perform indent
set smartindent
"does not create external files
set noswapfile
set nobackup
"Seaching
"moves to result as you type
set incsearch
"distinguish between upper and lower case when searching
set smartcase
"Highlight matches
set hlsearch
"Unless they contain at least one capital letter
set ignorecase
"tab of 4 spaces
set noexpandtab
set tabstop=4 shiftwidth=4
"Scheme
colorscheme gruvbox
let g:gruvbox_contrast_dark = "hard"
"set background=dark
"highlight Normal ctermbg=NONE
set laststatus=2
set noshowmode
" React
"set backupcopy=yes
"Fonts
set guifont=Hurmit_Nerd_Font_Mono:h12
"When a file is edited its indent file is loaded
filetype plugin indent on
"Encoding
set encoding=utf-8
Run Code Online (Sandbox Code Playgroud)
之前我只需要这个:
"enable copy and paste 'yy, p'
set clipboard=unnamed
Run Code Online (Sandbox Code Playgroud)
或者也许我在 Ubuntu 中缺少一些软件包来实现它,如果是的话你能告诉我吗?我已经疯狂搜索,只找到了以下解决方案:
" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
augroup END
endif
Run Code Online (Sandbox Code Playgroud)
但是,这不能反向工作,也就是说,如果我从 Windows 复制某些内容,则无法将其粘贴到 wsl 中
我有 ubuntu 20.04,与格式化之前的版本相同,并且我还安装了 xclip、tmux、zsh、python3、python2、nodejs
最后,当我做一个:%y我得到这个错误,我也尝试把let g: clipboard ...,但它也不起作用
Mat*_*att 10
Neovim 将剪贴板访问委托给外部应用程序。因为你没有任何它无法工作。上图中已经清楚地写给你了。
clip不支持Windows ,因为它无法从剪贴板读取;xclip不起作用,因为它需要 X-server 才能工作(从它的名字中不是很明显吗?)等等。
通常 Neovim 使用win32yank访问 Windows 剪贴板。因此,请尝试下载它并将其放在 WSL 路径上的某个位置。
let g:clipboard = {
\ 'name': 'win32yank-wsl',
\ 'copy': {
\ '+': '/path-file/win32yank.exe -i --crlf',
\ '*': '/path-file/win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '+': '/path-file/win32yank.exe -o --lf',
\ '*': '/path-file/win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7761 次 |
| 最近记录: |