1. 9

  2. 20

    I knew four. I feel cheated by a clickbait title.

    And about the one I didn’t know, I think it’s better to understand how to paste from the system clipboard using the verb for paste and the noun referring to the system clipboard.

    1. 6

      This gives me a post idea: “At least two things in vim you don’t know.” The post covers 30 different things. Statistically speaking, you don’t know at least two of them!

      1. 2

        Might steal that idea from you.

        1. 1

          I’d bet money that this llama would know all 30.

        2. 1

          I kinda feel cheated too. Actually, I feel mocked. Showing the line numbers? Seriously?

        3. 10

          However, often you may need to paste content from an external source. To do this, use the key combination: Ctrl+Shift+V

          Be careful with this. Vim reads it as a sequence of keystrokes, which can mess with autoindents. The issue might only happen with paste mode enabled, though- unsure.

          Pressing “ctrl+v” will enter visual mode with support for vertical highlighting

          v, V, and c_v can also be used as operators, to make the command character-wise, line-wise, or block-wise respectively. So d<c_v>10j will delete a 10-row, 1-column slice of your code. I use this a lot with search motions: yV/<regex> will yank until the search term, including the whole line containing the match.

          However, it is in fact possible to show line numbers in Vim. To do this, enter the following command: :set number

          You can also set relativenumber to show you the relative distance of each line from your cursor. If you have both number and relativenumber, it’ll be relative except for the line you’re on, which will be absolute.

          1. 4

            Ctrl+Shift+V is not a VIM shortcut, it is a terminal shortcut that is semi-standardized. That is why VIM “reads it as a sequence of keystrokes”. A sequence of keystrokes is exactly what VIM is getting.

            1. 3

              d<c_v>10j will delete a 10-row, 1-column slice of your code. I use this a lot with search motions: yV/ will yank until the search term,

              This I did not know, and is very cool!

              I caution that relativenumber causes your slower connections to lag something awful, due to random redrawing of every line in your terminal, but otherwise is cool.

              1. 1

                Vim supports bracketed paste for some time, so if you use fairly new terminal then there will be no problem.

              2. 10

                Note that Ctrl+Shift+V has nothing to do with Vim; it only happens to be the default paste shortcut in some popular terminal emulators. Vim’s paste option would have been worth mentioning here too.

                I agree with Vaelatern’s comment. The title had me expecting things I “Didn’t Know”. In my view, “5 Common Beginner Tasks in Vim” would’ve made for a more honest title.

                1. 6

                  Vim seems to have an incredibly long phase where you can call yourself “intermediate”, so that two experienced users can have two disjunct sets of things they know, “but most people don’t”.

                  1. 1

                    True. Am not surprised that a number of others in this thread already knew some of these tricks. I used Vim for ~5 years before discovering :autoindent, after which I promptly turned it off.

                  2. 5

                    This is pretty bad article:

                    1. This is only one of many completions supported by Vim, for more see :h ins-completion (line, keyword, word, tag, omni, user, file, thesaurus, dictionary).
                    2. This isn’t Vim feature. If you want to paste from system clipboard by using Vim then you need to use either + or * registers (so "+p to paste from system clipboard), for more information see :h registers.
                    3. This is called visual block mode, not vertical highlighting.
                    4. This is pretty known and IIRC it is presented even by vimtutor
                    5. If you have filetype indent somewhere in your .vimrc then that configuration option changes almost nothing.

                    In other words, these are fairly known features and you really need to bump your Vim game before writing such articles.

                    1. 4

                      Ooh, a Vim thread! One I discovered by accident the other day: the command-mode versions of the normal->insert mode i and a, i.e. :i and :a. They put you in a mini (insert-mode) buffer that you can edit independently of the surrounding text before committing to the insert with escape.

                      1. 2

                        Showing the line numbers in the gutter is not particularly useful; you have this in the status bar anyway. Using relativenumber is useful and I used it for a long time, but I remember disabling it for performance reasons. It’s better to get comfortable with text objects anyway.

                        Also, I’m fairly certain the “vertical selection” mode is actually called visual block mode. To be honest, I’d consider this basic.

                        1. 3

                          Showing numbers in the gutter is incredibly useful for ex commands, like :4,7co $. I know some people define an augroup to switch on number whenever they enter the command mode.

                          1. 2

                            Ah, fair point. Personally, I would jump into command mode from a line-wise visual selection (which gives you :'<,'>), which I find less mentally taxing and easier to type. I don’t have really have digits dialled into my muscle memory.

                        2. 1

                          Bleh, kind of a weak article.

                          I’ve been enjoying a Vim series by the “FrugalComputerGuy” (https://www.youtube.com/user/TheFrugalComputerGuy/videos)

                          However my personal goal is to just RTFM and practice more. https://www.vi-improved.org/vimusermanual.pdf (Yeah, I know this is the contents of :help, but nice to be able to read/print as a PDF.)

                          1. 1

                            A much better way to interact with OS clipboard is to prepend the command with “+.

                            Aside from that, did author really think that there exists a Vim user who thinks that Vim can’t show line numbers? Even if you just started using it and don’t know how to do that, you probably expect such a basic feature from a text editor so well known for it’s geek cred.

                            1. 3


                              # in your ~/.vimrc
                              set clipboard=unnamed

                              This should make the system clipboard “just work”, unless you’re in tmux, in which case you need to also do this (choosing the appropriate shell):

                              # in your ~/.tmux.config
                              set-option -g default-command "reattach-to-user-namespace -l zsh"
                              1. 1

                                This I indeed didn’t know, thank you!