1

I have tried unsuccessfully to copy the pwd to pbcopy as follows

pwd | !pbcopy

How can you copy your path in Vim's ED editor (: -mode)?

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

2 Answers2

2

A lot of ways

in terminal
pwd | !pbcopy
and then in vim
"*p

in vim
:!r pwd
or in insert mode
<C-R>=getcwd()<CR>
or
<C-R>=system('pwd')<CR>

Current file location to the clipboard

:let @*=expand('%:p:h')

Current vim dir to the clipboard

:let @*=getcwd()
Mykola Golubyev
  • 57,943
  • 15
  • 89
  • 102
2

Why not :!pwd|pbcopy?

Use the command

cd

to the current working directory if needed with the command

lcd %:p:h
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
jmdeldin
  • 5,354
  • 1
  • 28
  • 21