Skip to content

Instantly share code, notes, and snippets.

@llinfeng
Created January 28, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llinfeng/18844f4033350cc777bee3dfbe926265 to your computer and use it in GitHub Desktop.
Save llinfeng/18844f4033350cc777bee3dfbe926265 to your computer and use it in GitHub Desktop.
For Xming-illustrated-Gvim-from-WSL on Windows 10, pressing `<c-c>` writes to registry `+` and `<c-v>` shall past from registry `+`. This is different from Win-Gvim's behavior, where `*`-registry is used.
" Snippet from my ~/.vimrc, where I use `Y` for fetching the absolute path, and use `<leader><leader>n` to fetch the name of the file.
" Other mappings were done a while ago. Kept for potential audience as they do demonstrate a wide variety of flags applicable for the expand() function.
if has('win32')
"Copy the full file path to windows clipboard.
nnoremap Y :let @* = expand("%:p")<CR>
"Copy the file name to windows clipboard.
nnoremap yyy :let @* = expand("%:p:t")<CR>
"Now using leaders:
" Full path
nnoremap <leader><leader>f :let @* = expand("%:p")<CR>
" Parent directory, full.
nnoremap <leader><leader>p :let @* = expand("%:p:h")<CR>
" File Name only, without extension
nnoremap <leader><leader>n :let @* = expand("%:t:r")<CR>
" Extension.
nnoremap <leader><leader>e :let @* = expand("%:t:e")<CR>
" Copy the line number with file name
nnoremap <leader><leader>l :let @* = expand("%:p").":".line(".")<CR>
else
"Copy the full file path to windows clipboard.
nnoremap Y :let @+ = expand("%:p")<CR>
"Copy the file name to windows clipboard.
nnoremap yyy :let @+ = expand("%:p:t")<CR>
"Now using leaders:
" Full path
nnoremap <leader><leader>f :let @+ = expand("%:p")<CR>
" Parent directory, full.
nnoremap <leader><leader>p :let @+ = expand("%:p:h")<CR>
" File Name only, without extension
nnoremap <leader><leader>n :let @+ = expand("%:t:r")<CR>
" Extension.
nnoremap <leader><leader>e :let @+ = expand("%:t:e")<CR>
" Copy the line number with file name
nnoremap <leader><leader>l :let @+ = expand("%:p").":".line(".")<CR>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment