Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: quick column insert

Tags:

vim

I have been using Vim for my text editor in place the notepad++. I want to know is there a way to perform "quick column insert" in vim.

As I know, we are able to perform column insert in vim in following steps:

  1. move to the position
  2. enter column visual mode CTRL+v
  3. select the column j or k
  4. enter into column insert mode shift+i
  5. insert the text
  6. type Esc

then the column insertion is performed

is there a way to delete the step 4 and perform column insertion directly?

like image 472
alexzzp Avatar asked Dec 04 '12 11:12

alexzzp


People also ask

How do I go to a column in ViM?

The | command does what you want, as in 3 0 | will take you to column 30. bar | To screen column [count] in the current line. exclusive motion.

How do I select a column in vi editor?

To use it, press: Ctrl + V to go into column mode. Select the columns and rows where you want to enter your text.


1 Answers

I use the following mappings that allow to prepend / append spaces (also multiple with a [count] before the mapping):

:vnoremap <C-Space> I<Space><Esc>gv
:vnoremap <C-S-Space> A<Space><Esc>gv

Custom mappings such as these are the key to efficient editing, and very powerful in Vim. You'll find all the details in the :help.

like image 137
Ingo Karkat Avatar answered Oct 24 '22 02:10

Ingo Karkat