3

I'm trying to paste from Google Chrome into my terminal running vim but for some reason the code gets cut off.

For example I'll copy:

{% extends 'blog/base.html' %}
{% block content %}
    <h1>New post</h1>
    <form method="POST" class="post-form">{% csrf_token %}
        {{ form.as_p }}
        <button type="submit" class="save btn btn-default">Save</button>
    </form>
{% endblock %}

But then it will come out as:

g/base.html' %}

{% block content %}
    <h1>New post</h1>
    <form method="POST" class="post-form">{% csrf_token %}
        {{ form.as_p }}
        <button type="submit" class="save btn btn-default">Save</button>
    </form>
{% endblock %}
2
  • How are you pasting the text in? Looks like you're using <CTRL>-v (or equivalent) in normal mode, which simply sends all characters to vim. This means that up until you get to a character that enters insert mode nothing actually gets pasted in. Either go into insert mode first (and you probably want to :set paste first), or use either "+p or "*p (depending on the clipboard used to copy the text) in normal mode. Commented Sep 8, 2017 at 19:15
  • Automatically set paste mode in Vim when pasting in insert mode Commented Sep 9, 2017 at 10:21

2 Answers 2

3

To paste copied text in verbatim, enable :set paste and be in insert mode and paste it.

You may like to set pastetoggle to a key also. :help pastetoggle.

As being in paste mode is not preferred due to its repercussions, set paste mode only when required.

Sign up to request clarification or add additional context in comments.

Comments

2

It happens because you have to enter insert mode first when using system-wide shortcuts like Ctrlp for pasting.

Otherwise Vim interprets everything you paste as commands. This is why it start pasting after {% extends 'blo - o is a command which enters insert mode.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.