New answers tagged

1

From :h visual-use (emphasis mine): Using Visual mode consists of three parts: Mark the start of the text with "v", "V" or CTRL-V. The character under the cursor will be used as the start. Move to the end of the text. The text from the start of the Visual mode up to and including the character under the cursor is highlighted. Type an ...


2

Yes, pressing some keys in Vim could switch the current mode. Still surprised? This is documented under :h mode-switching. Obviously, here you have even two transitions: one by colon, and another one by enter key. But, I admit, it's confusing on the first encounter. In Neovim they even invented :h <Cmd> to deal with this. But in plain Vim you have only ...


4

You can use blockwise Visual mode to select a block of columns and insert text (such as one or two spaces) in front of the block. Likewise, you can also use blockwise Visual mode to delete one or two columns of spaces in order to unindent lines. To add indentation: Go to the first line of the block. Use 0 (or ^) to move to the first column (or first ...


1

The problem occurred because there is an inconsistency between the spaces and tabs used for indentation in your code. You have probably opened a tab indented code, and started editing it, while vim was set to indent using spaces. To solve this issue, first, set your tabbing space setting in your ~/.vim/vimrc by set softtabstop=4 set tabstop=4 set shiftwidth=...


4

One thought that occurs to me: yank the text (y), and then paste it at the :grep command: :grep <C-r>" ... Note that this doesn't work too well for multi-line selections, and you may want something more like <C-r>=escape(@", '/\')<CR> to handle some escape sequences. I'm making use of the "insert register" keystroke (:...


Top 50 recent answers are included