vim column editing mode

vim column editing mode

Tags: vim window mode column editing mode


  • vim column editing mode
  • Example: to add bulk to the column prefixes, suffixes, modify the field

vim column editing mode

vim has three edit modes, command mode, input mode, Windows mode, we used the first two models, but still very good window mode, enter the vim editor mode is command mode, can i , A to enter input, etc. mode, can also V , C + V into the window mode.

Windows mode allows us to select an area, this area is like a window view, you can batch edit.

Example 1: Column bulk to add a prefix, suffix, modify

We often have such a scenario, the need for Excel , CSV edit a column, for example, add some prefix, suffix, or modify, in general maintenance data or bulk to generate some sql statement is very common.

Then we look at an example: We need to generate a set of test data, this set of data you need to add sql insert prefix, we can batch poured into DB to go.

We simply generating a set of test data:

for ((i=1;i<=10000;i++))
do echo $RANDOM >> ids.csv
do

We need to add to this group id in the DB, vim to edit this file.

vim ids.csv

vim

Into command mode is turned on by default, this time we need to add sql code before and after the column. c + v into visualization mode.
vim

Then GG jump to the last line, then L select the current column to the right. shit + i before switching to the input column.
vim

Then enter sql insert statement.

insert into tb_ids(id) values (

Then esc exit View mode, automatically generates a prefix for all rows.
vim

We continue to add columns suffix portion. And before the editing mode is the same, but all use after check shit + a cut to the back-end column.

Input insert sql end portion.

);

vim

Of course there will be some issues that need attention, columns need to be regular, if there is no need to rule column to sort good and batch processing. If the entire line mode, you can directly v mode the entire line into the edit mode. vim functionality is still very rich, but here to share a very simple example.

Author: Wang Qingpei (Fun headlines Tech Leader)

Guess you like

Origin www.cnblogs.com/wangiqngpei557/p/11105846.html