# Identation lines in vim get copied/pasted

**URL:** <https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889>\
**Category:** Offtopic\
**Tags:** vim\
**Created:** [June 14, 2021, 12:59pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889 "2021-06-14T12:59:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 14, 2021, 12:59pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/1 "2021-06-14T12:59:21Z")

</div>

I have installed this vim plugin to have identation lines in vim: [GitHub - Yggdroot/indentLine: A vim plugin to display the indention levels with thin vertical lines](https://github.com/Yggdroot/indentLine)

Now I have noticed that if I copy and paste something from vim to the REPL, the identation characters are copied and pasted as well, of course invalidating the code:

```julia
function f(x)
  if x == 1
  │ println(x) # < the | was pasted here... 
  end
end

```

Anyone had a similar experience with that? Do you use this with some workaround, or any other alternative to get identation lines in vim without this issue?

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [June 14, 2021, 1:31pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/2 "2021-06-14T13:31:50Z")

</div>

It uses conceal feature of the vim, so the question is how do you copy? Usual `yank` operations should copy original text instead of the overlay. Mouse selection on the other hand copies visual text.

By the way, vim beautifier is rather good, so usual `ggVG=` should work just fine to fix all idents.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 14, 2021, 1:35pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/3 "2021-06-14T13:35:24Z")

</div>

Indeed, I am not copying within the same file, so either I am using a mouse selection, or “shift-control-c”.

(copying with the standard yanking of vim to the same file is fine).

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [June 14, 2021, 1:36pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/4 "2021-06-14T13:36:19Z")

</div>

You can use `"+y` or `"*y` (depends on your OS) to copy to mouse buffer and than use it in another window.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 14, 2021, 1:39pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/5 "2021-06-14T13:39:55Z")

</div>

Thanks, that helps, won’t be bad to finger-memorize those as well. Yet I will still search for a solution that allows me to use the mouse selection/middle-click, which is very handy many times.

(for instance [this one](https://github.com/nathanaelkane/vim-indent-guides) does not have that issue, yet it looks horrible in my terminal)

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [June 14, 2021, 1:46pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/6 "2021-06-14T13:46:24Z")

</div>

I doubt that it is possible, since mouse selection and conceal-like things are orthogonal to each other.

You can either try to setup proper colors in `nathanaelkane/vim-indent-guides`. It’ll work properly with mouse selection, since it doesn’t change text, only colouring, and colours are not copied in mouse buffer.

Or you can set hotkey to toggle lines on and off and switch them back and forth when you need to copy text.

This question is tangential to the topic, but have you tried [iron.nvim](https://github.com/hkupty/iron.nvim)? It has embedded support of REPL, so there is no need to copy text to another window. Or alternatively [vim-slime](https://github.com/jpalardy/vim-slime). I am using both and I never had a need to copy paste code somewhere.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 14, 2021, 1:53pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/7 "2021-06-14T13:53:47Z")

</div>

Yes, I have vim-slime installed and use it some times. But I could not naturalize it enough to not get distracted by yet another command… I will try to setup the colors of that plugin.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [June 14, 2021, 2:06pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/8 "2021-06-14T14:06:53Z")

</div>

I am using `iron.nvim` and have these hotkeys:

```julia
vmap <F2> <Plug>(iron-visual-send)
nmap <F2> <Plug>(iron-send-line)
nnoremap <leader>is :IronRepl<CR>
nnoremap <leader>ir :IronRestart<CR><C-w>p<C-W>L<C-w>p

```

Now, with `\is` I can start new julia REPL and with `F2` send either line or visual selection to REPL. It is very convenient, I even made small ascii video about it: [untitled - asciinema](https://asciinema.org/a/zt311WEOur8AMGtHW4cN9bGoo)

This is easy to setup and easy to use. No need for IDE anymore 🙂

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 14, 2021, 2:17pm UTC](https://discourse.julialang.org/t/identation-lines-in-vim-get-copied-pasted/62889/9 "2021-06-14T14:17:45Z")

</div>

Indeed, with vim-slime and gnu-screen (which are the things I’m used to) I can do something like that. I guess I can use it more often now and disable the identation lines when needed 🙂 (customizing the colors of the other plugin to something I like I noticed that will take me one day of work… so I will leave that option for now).
