Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Using VIM visual blocks

Old News ;-) VIM -- VI-style Editor with folding capabilities Recommended Links VIM visual blocks Vim Buffers and Text-buffer Execution .vimrc VIM Exrc file VIM Multiwindows Support
Piping Vim Buffer   File managers in VIM Copying and Moving sections of text Vim Regular Expressions Vim Options and Set command Searching and replacing text in VI
Indenting Your Code in VIM Outliner VIM running external commands Searching and replacing text in VI Ctags code browsing framework Perl one-liners  
Line Ranges Vim documentation: if_perl Tips VIM Perl Support Humor History Etc

Visual selection is a common feature in applications, but Vim's visual selection has several benefits.

To cut-and-paste or copy-and-paste:

  1. Position the cursor at the beginning of the text you want to cut/copy.
  2. Press v  to begin character-based visual selection, or V  to select whole lines, or Ctrl-v or Ctrl-q to select a block.
  3. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement.
  4. Press d  (delete) to cut, or y  (yank) to copy. You can yank to any of 24 named 
  5. Move the cursor to the desired paste location.
  6. Press p  to paste after the cursor, or P  to paste before.

Visual selection (steps 1-3) can be performed using a mouse.

If you want to change the selected text, press c  instead of d  or y  in step 4. In a visual selection, pressing c  performs a change by deleting the selected text and entering insert mode so you can type the new text.

Pasting over a block of text

You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank. Now you can move elsewhere and press p to paste the text after the cursor (or P to paste before). The paste inserts a block (which might, for example, be 4 rows by 3 columns of text).

Instead of inserting the block, it is also possible to replace (paste over) the destination. To do this, move to the target location then press 1vp (1v selects an area equal to the original, and p pastes over it).

When a count is used before v, V, or ^V (character, line or block selection), an area equal to the previous area, multiplied by the count, is selected. See the paragraph after :help <LeftRelease>.

Note that this will only work if you actually did something to the previous visual selection, such as a yank, delete, or change operation. It will not work after visually selecting an area and leaving visual mode without taking any actions.

CommentsEdit

NOTE: after selecting the visual copy mode, you can hold the shift key while selection the region to get a multiple line copy. For example, to copy three lines, press V, then hold down the Shift key while pressing the down arrow key twice. Then do your action on the buffer.

I have struck out the above new comment because I think it is talking about something that may apply to those who have used :behave mswin. To visually select multiple lines, you type V, then press j (or cursor down). You hold down Shift only to type the uppercase V. Do not press Shift after that. If I am wrong, please explain here. JohnBeckett 10:48, October 7, 2010 (UTC)

If you just want to copy (yank) the visually marked text, you do not need to 'y'ank it. Marking it will already copy it.

Using a mouse, you can insert it at another position by clicking the middle mouse button.

This also works in across Vim applications on Windows systems (clipboard is inserted)


This is a really useful thing in Vim. I feel lost without it in any other editor. I have some more points I'd like to add to this tip:


You can replace a set of text in a visual block very easily by selecting a block, press c and then make changes to the first line. Pressing <Esc> twice replaces all the text of the original selection. See :help v_b_c.


On Windows the <mswin.vim> script seems to be getting sourced for many users.

Result: more Windows like behavior (ctrl-v is "paste", instead of visual-block selection). Hunt down your system vimrc and remove sourcing thereof if you don't like that behavior (or substitute <mrswin.vim> in its place, see VimTip63.

With VimTip588 one can sort lines or blocks based on visual-block selection.


With reference to the earlier post asking how to paste an inner block

  1. Select the inner block to copy usint ctrl-v and highlighting with the hjkl keys
  2. yank the visual region (y)
  3. Select the inner block you want to overwrite (Ctrl-v then hightlight with hjkl keys)
  4. paste the selection P (that is shift P) , this will overwrite keeping the block formation

The "yank" buffers in Vim are not the same as the Windows clipboard (i.e., cut-and-paste) buffers. If you're using the yank, it only puts it in a Vim buffer - that buffer is not accessible to the Windows paste command. You'll want to use the Edit | Copy and Edit | Paste (or their keyboard equivalents) if you're using the Windows GUI, or select with your mouse and use your X-Windows cut-n-paste mouse buttons if you're running UNIX.


Double-quote and star gives one access to windows clippboard or the unix equivalent. as an example if I wanted to yank the current line into the clipboard I would type "*yy

If I wanted to paste the contents of the clippboard into Vim at my current curser location I would type "*p

The double-qoute and start trick work well with visual mode as well. ex: visual select text to copy to clippboard and then type "*y

I find this very useful and I use it all the time but it is a bit slow typing "* all the time so I am thinking about creating a macro to speed it up a bit.


Copy and Paste using the System Clipboard

There are some caveats regarding how the "*y (copy into System Clipboard) command works. We have to be sure that we are using vim-full (sudo aptitude install vim-full on debian-based systems) or a Vim that has X11 support enabled. Only then will the "*y command work.

For our convenience as we are all familiar with using Ctrl+c to copy a block of text in most other GUI applications, we can also map Ctrl+c to "*y so that in Vim Visual Mode, we can simply Ctrl+c to copy the block of text we want into our system buffer. To do that, we simply add this line in our .vimrc file:

map <C-c> "+y<CR>

Restart our shell and we are good. Now whenever we are in Visual Mode, we can Ctrl+c to grab what we want and paste it into another application or another editor in a convenient and intuitive manner

Simple Example

The best way to understand this feature is by way of an example. Imagine you have the following content (also imagine, if you will, that this list is much longer, maybe a hundred lines or more in length):

_List Item 1
_List Item 2
_List Item 3
_List Item 4
_List Item 5

If you wanted to remove the _ (underscore) character that begins every line, you could fix this using VISUAL-BLOCK mode. (You could also use a substitution command, but that option has a more complex syntax, and so I'll cover it in another chapter.)

To begin with, we have to enter VISUAL-BLOCK mode. To do this, you will have to run <C-v> from NORMAL mode.

To implement the change we've described above (i.e., removing the underscores), we have to run the following sequence of commands:

gg<C-v>Gd

By now, you should be comfortable analyzing the construction of complex commands, but let's take a look at what this command does when we break it down into its component parts.

Note A nice side effect of using a visual mode (whether it be a VISUAL-BLOCK or standard visual selection) is that you can filter content through an external terminal program, using the ! operator. We'll see more examples of this in Chapter 20.

Canceling

To escape from VISUAL-BLOCK mode, you will have to run the command <Esc>, which will take you back into NORMAL mode. But realize that if you have started to insert or append content across a selection, pressing <Esc> will still apply the changes you have started to make.

If you would prefer to not have the changes applied across all selected lines, you would instead have to run the command <C-c>, which will keep the changes you've made to the current line but not apply them automatically to any other selected lines.

Adding Additional Content in Block Format

As well as being able to select a rectangular area and execute operators upon that selection, you can also add additional content, which gets automatically applied across the multiple lines you have selected within VISUAL-BLOCK mode. To demonstrate this, let's look at the modified version of the previous "simple example" content we had (notice the underscore character has been removed from each line).

List Item 1
List Item 2
List Item 3
List Item 4
List Item 5

If we wanted to add an asterisk character (*) to the start of each line, we could do so very easily with VISUAL-BLOCK mode. First, we would have to enter VISUAL-BLOCK mode, make our selection, and then insert the content we wanted to be applied around that selection. The specific command would be as follows:

gg<C-v>4jI*<Esc>

Running that command would result in the content being changed to the following:

*List Item 1
*List Item 2
*List Item 3
*List Item 4
*List Item 5

Let's break down the command, so that we can see what we did and, in the process, learn how to inject new content that is automatically applied to a selection.

Note You can also use other commands, such as c, to change multiple lines, or s, to substitute the content across multiple lines, but remember that your change will only appear once you escape VISUAL-BLOCK mode.

End-of-Line Concerns

Interestingly, Vim's VISUAL-BLOCK mode is intelligent enough to know that when we want to insert some content (or apply a change) at the end of a line, that the end of the line will be different each time.

Imagine our content looks like the following:

pro javascript design patterns
practical clojure
beginning ruby
regular expression recipes
practical common lisp

If we wanted to add an exclamation point to the end of each line, using VISUAL-BLOCK mode, we would have to use the $ operator at some point during our command, to tell Vim to move to the end of the line. But as you can see, the end of the line is different for each line, as some book titles are longer than others.

Let's run the command that implements the solution: gg<C-v>$4jA!<Esc>. (Don't worry, we'll come back and explain this command in a moment.) Once we run this command, we'll see that the result has the following content (note that the exclamation marks [!] on each line aren't placed at the same point as the longest line but are placed perfectly at the relevant position for each line):

pro javascript design patterns!
practical clojure!
beginning ruby!
regular expression recipes!
practical common lisp!

So let's take a moment to quickly explain the command we ran. (You should have been able to analyze and figure it out yourself by now; if not, then I'd suggest going back and reading Chapter 5 on how to read and run commands in Vim.)


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Oct 22, 2018] move selection to a separate file

Highly recommended!
Oct 22, 2018 | superuser.com

greg0ire ,Jan 23, 2013 at 13:29

With vim, how can I move a piece of text to a new file? For the moment, I do this:

Is there a more efficient way to do this?

Before

a.txt

sometext
some other text
some other other text
end
After

a.txt

sometext
end

b.txt

some other text
some other other text

Ingo Karkat, Jan 23, 2013 at 15:20

How about these custom commands:
:command! -bang -range -nargs=1 -complete=file MoveWrite  <line1>,<line2>write<bang> <args> | <line1>,<line2>delete _
:command! -bang -range -nargs=1 -complete=file MoveAppend <line1>,<line2>write<bang> >> <args> | <line1>,<line2>delete _

greg0ire ,Jan 23, 2013 at 15:27

This is very ugly, but hey, it seems to do in one step exactly what I asked for (I tried). +1, and accepted. I was looking for a native way to do this quickly but since there does not seem to be one, yours will do just fine. Thanks! – greg0ire Jan 23 '13 at 15:27

Ingo Karkat ,Jan 23, 2013 at 16:15

Beauty is in the eye of the beholder. I find this pretty elegant; you only need to type it once (into your .vimrc). – Ingo Karkat Jan 23 '13 at 16:15

greg0ire ,Jan 23, 2013 at 16:21

You're right, "very ugly" shoud have been "very unfamiliar". Your command is very handy, and I think I definitely going to carve it in my .vimrc – greg0ire Jan 23 '13 at 16:21

embedded.kyle ,Jan 23, 2013 at 14:08

By "move a piece of text to a new file" I assume you mean cut that piece of text from the current file and create a new file containing only that text.

Various examples:

The above only copies the text and creates a new file containing that text. You will then need to delete afterward.

This can be done using the same range and the d command:

Or by using dd for the single line case.

If you instead select the text using visual mode, and then hit : while the text is selected, you will see the following on the command line:

:'<,'>

Which indicates the selected text. You can then expand the command to:

:'<,'>w >> old_file

Which will append the text to an existing file. Then delete as above.


One liner:

:2,3 d | new +put! "

The breakdown:

greg0ire, Jan 23, 2013 at 14:09

Your assumption is right. This looks good, I'm going to test. Could you explain 2. a bit more? I'm not very familiar with ranges. EDIT: If I try this on the second line, it writes the first line to the other file, not the second line. – greg0ire Jan 23 '13 at 14:09

embedded.kyle ,Jan 23, 2013 at 14:16

@greg0ire I got that a bit backward, I'll edit to better explain – embedded.kyle Jan 23 '13 at 14:16

greg0ire ,Jan 23, 2013 at 14:18

I added an example to make my question clearer. – greg0ire Jan 23 '13 at 14:18

embedded.kyle ,Jan 23, 2013 at 14:22

@greg0ire I corrected my answer. It's still two steps. The first copies and writes. The second deletes. – embedded.kyle Jan 23 '13 at 14:22

greg0ire ,Jan 23, 2013 at 14:41

Ok, if I understand well, the trick is to use ranges to select and write in the same command. That's very similar to what I did. +1 for the detailed explanation, but I don't think this is more efficient, since the trick with hitting ':' is what I do for the moment. – greg0ire Jan 23 '13 at 14:41

Xyon ,Jan 23, 2013 at 13:32

Select the text in visual mode, then press y to "yank" it into the buffer (copy) or d to "delete" it into the buffer (cut).

Then you can :split <new file name> to split your vim window up, and press p to paste in the yanked text. Write the file as normal.

To close the split again, pass the split you want to close :q .

greg0ire ,Jan 23, 2013 at 13:42

I have 4 steps for the moment: select, write, select, delete. With your method, I have 6 steps: select, delete, split, paste, write, close. I asked for something more efficient :P – greg0ire Jan 23 '13 at 13:42

Xyon ,Jan 23, 2013 at 13:44

Well, if you pass the split :x instead, you can combine writing and closing into one and make it five steps. :P – Xyon Jan 23 '13 at 13:44

greg0ire ,Jan 23, 2013 at 13:46

That's better, but 5 still > 4 :P – greg0ire Jan 23 '13 at 13:46 Based on @embedded.kyle's answer and this Q&A , I ended up with this one liner to append a selection to a file and delete from current file. After selecting some lines with Shift+V , hit : and run:
'<,'>w >> test | normal gvd

The first part appends selected lines. The second command enters normal mode and runs gvd to select the last selection and then deletes.

[Oct 21, 2018] Common visual block selection scenarios

Notable quotes:
"... column oriented ..."
Oct 21, 2018 | stackoverflow.com
You are talking about text selecting and copying, I think that you should give a look to the Vim Visual Mode .

In the visual mode, you are able to select text using Vim commands, then you can do whatever you want with the selection.

Consider the following common scenarios:

You need to select to the next matching parenthesis.

You could do:

You want to select text between quotes:

You want to select a curly brace block (very common on C-style languages):

You want to select the entire file:

Visual block selection is another really useful feature, it allows you to select a rectangular area of text, you just have to press Ctrl - V to start it, and then select the text block you want and perform any type of operation such as yank, delete, paste, edit, etc. It's great to edit column oriented text.

Vim cheatcheet.

Marking text (visual mode)

Visual commands

Cut and Paste

typing : would add the block to ex command line and low you touse ex commans with the block inclide mo command is :'<,'> mo 15. This means move visual blok toposition after line 15. the target can be bookmark

:'<,'> mo mark a

Using registers to moving blocks

"<letter>y

7 uu Making it even quicker:
6
5 If •+y and "+p are too many keypresses, we can easily remap
4 the copy and paste commands.
3
2
1 vnoremap <C-c> "+y
map <C-fc "+p
1 ...
2
3 You might want to consider using P instead of p.
4
5 For copying to both the clipboard and primary selection.
6
7 ... ... ...
8 vnoremap <C-c> "*y :let @+=@**<CR>
9
0

[Oct 19, 2018] Visual Mode

Notable quotes:
"... Vim's Operator Commands ..."
Oct 19, 2018 | my.safaribooksonline.com

Vim's Visual mode allows us to define a selection of text and then operate upon it. This should feel pretty intuitive, since it is the model that most editing software follows. But Vim's take is characteristically different, so we'll start by making sure we grok Visual mode ( Tip 20 ).

Vim has three variants of Visual mode involving working with characters, lines, or rectangular blocks of text. We'll explore ways of switching between these modes as well as some useful tricks for modifying the bounds of a selection ( Tip 21 ).

We'll see that the dot command can be used to repeat Visual mode commands, but that it's especially effective when operating on line-wise regions. When working with character-wise selections, the dot command can sometimes fall short of our expectations. We'll see that in these scenarios, operator commands may be preferable.

Visual-Block mode is rather special in that it allows us to operate on rectangular columns of text. You'll find many uses for this feature, but we'll focus on three tips that demonstrate some of its capabilities.

Visual mode allows us to select a range of text and then operate upon it. However intuitive this might seem, Vim's perspective on selecting text is different from other text editors.

Suppose for a minute that we're not working with Vim but instead filling out a text area on a web page. We've written the word "March," but it should read "April," so using the mouse, we double-click the word to select it. Having highlighted the word, we could hit the backspace key to delete it and then type out the correct month as a replacement.

You probably already know that there's no need to hit the backspace key in this example. With the word "March" selected, we would only have to type the letter "A" and it would replace the selection, preparing the way so that we could type out the rest of the word "April." It's not much, but a keystroke saved is a keystroke earned.

If you expect this behavior to carry over to Vim's Visual mode, you're in for a surprise. The clue is right there in the name: Visual mode is just another mode, which means that each key performs a different function.

Many of the commands that you are familiar with from Normal mode work just the same in Visual mode. We can still use h , j , k , and l as cursor keys. We can use f{char} to jump to a character on the current line and then repeat or reverse the jump with the ; and , commands, respectively. We can even use the search command (and n / N ) to jump to pattern matches. Each time we move our cursor in Visual mode, we change the bounds of the selection.

Some Visual mode commands perform the same basic function as in Normal mode but with a slight twist. For example, the c command is consistent in both modes in that it deletes the specified text and then switches to Insert mode. The difference is in how we specify the range on which to act. From Normal mode, we trigger the change command first and then specify the range as a motion. This, if you'll remember from Tip 12 , is called an operator command. Whereas in Visual mode, we start off by making the selection and then trigger the change command. This inversion of control can be generalized for all operator commands (see Table 2, ​ Vim's Operator Commands ). For most people, the Visual mode approach feels more intuitive.

Let's revisit the simple example where we wanted to change the word "March" to "April." This time, suppose that we have left the confines of the text area on a web page and we're comfortably back inside Vim. We place our cursor somewhere on the word "March" and run viw to visually select the word. Now, we can't just type the word "April" because that would trigger the A command and append the text "pril"! Instead, we'll use the c command to change the selection, deleting the word and dropping us into Insert mode, where we can type out the word "April" in full. This pattern of usage is similar to our original example, except that we use the c key instead of backspace.

Meet Select Mode

In a typical text editing environment, selected text is deleted when we type any printable character. Vim's Visual mode doesn't follow this convention -- but Select mode does. According to Vim's built-in documentation, it "resembles the selection mode in Microsoft Windows" (see Select-mode ). Printable characters cause the selection to be deleted, Vim enters Insert mode, and the typed character is inserted.

We can toggle between Visual and Select modes by pressing <C-g> . The only visible difference is the message at the bottom of screen, which switches between -- VISUAL -- and -- SELECT -- . But if we type any printable character in Select mode, it will replace the selection and switch to Insert mode. Of course, from Visual mode you could just as well use the c key to change the selection.

If you are happy to embrace the modal nature of Vim, then you should find little use for Select mode, which holds the hand of users who want to make Vim behave more like other text editors. I can think of only one place where I consistently use Select mode: when using a plugin that emulates TextMate's snippet functionality, Select mode highlights the active placeholder.

[Oct 19, 2018] Vim faster way to select blocks of text in visual mode - Stack Overflow

Oct 19, 2018 | stackoverflow.com

Vim: faster way to select blocks of text in visual mode Ask Question up vote 149 down vote favorite 65


Calvin Cheng ,Sep 13, 2011 at 18:52

I have been using vim for quite some time and am aware that selecting blocks of text in visual mode is as simple as SHIFT + V and moving the arrow key up or down line-by-line until I reach the end of the block of text that I want selected.

My question is - is there a faster way in visual mode to select a block of text for example by SHIFT + V followed by specifying the line number in which I want the selection to stop? (via :35 for example, where 35 is the line number I want to select up to - this obviously does not work so my question is to find how if something similar to this can be done...)

user786653 ,Sep 13, 2011 at 19:08

+1 Good question as I have found myself doing something like this often. I am wondering if perhaps this isn't the place start using using v% or v/pattern or something else? – user786653 Sep 13 '11 at 19:08

SergioAraujo ,Sep 13, 2011 at 20:30

vip select inner paragraph vis select inner sentence. – SergioAraujo Sep 13 '11 at 20:30

Stephan ,Sep 29, 2014 at 22:49

V35G will visually select from current line to line 35, also V10j or V10k will visually select the next or previous 10 lines – Stephan Sep 29 '14 at 22:49

shriek ,Feb 20, 2015 at 4:28

@Stephan, that's just what I was looking for. Thanks!! – shriek Feb 20 '15 at 4:28

Mikhail V ,Mar 27, 2015 at 16:52

for line selecting I use shortcut: nnoremap <Space> V . When in visual line mode just right-click with mouse to define selection (at least on linux it is so). Anyway, more effective than with keyboard only. – Mikhail V Mar 27 '15 at 16:52

Jay ,Sep 13, 2011 at 19:05

In addition to what others have said, you can also expand your selection using pattern searches.

For example, v/foo will select from your current position to the next instance of "foo." If you actually wanted to expand to the next instance of "foo," on line 35, for example, just press n to expand selection to the next instance, and so on.

update

I don't often do it, but I know that some people use marks extensively to make visual selections. For example, if I'm on line 5 and I want to select to line 35, I might press ma to place mark a on line 5, then :35 to move to line 35. Shift + v to enter linewise visual mode, and finally `a to select back to mark a .

Calvin Cheng ,Sep 13, 2011 at 19:19

now this is COOL. Thanks! – Calvin Cheng Sep 13 '11 at 19:19

Peter Rincker ,Sep 13, 2011 at 19:41

If you need to include the pattern you can use v/foo/e . The e stands for "end" of the matched pattern. – Peter Rincker Sep 13 '11 at 19:41

bheeshmar ,Sep 13, 2011 at 20:29

And you can modify from that line with offsets: V/foo/+5 or V/foo/-5 (I'm using linewise visual mode like the author). – bheeshmar Sep 13 '11 at 20:29

Jay ,Oct 31, 2013 at 0:18

@DanielPark To select the current word, use v i w . If you want to select the current contiguous non-whitespace, use v i Shift + w . The difference would be when the caret is here MyCla|ss.Method , the first combo would select MyClass and second would select the whole thing. – Jay Oct 31 '13 at 0:18

Daniel Park ,Oct 31, 2013 at 1:55

Thanks. Found that also using v i w s allows you to effectively do a "replace" operation. – Daniel Park Oct 31 '13 at 1:55

bheeshmar ,Sep 13, 2011 at 19:00

G                       Goto line [count], default last line, on the first
                        non-blank character linewise.  If 'startofline' not
                        set, keep the same column.
                        G is a one of jump-motions.

V35G achieves what you want

Daniel Kobe ,Apr 24, 2017 at 18:16

My vim gives me the error Not an editor command: VDaniel Kobe Apr 24 '17 at 18:16

kzh ,Apr 24, 2017 at 19:42

@Daniel vimdoc.sourceforge.net/htmldoc/visual.html#Vkzh Apr 24 '17 at 19:42

bheeshmar ,Apr 25, 2017 at 19:06

@DanielKobe, it's a Normal mode command, so don't press ":". – bheeshmar Apr 25 '17 at 19:06

kzh ,Jun 1, 2013 at 12:29

Vim is a language. To really understand Vim, you have to know the language. Many commands are verbs, and vim also has objects and prepositions.
V100G
V100gg

This means "select the current line up to and including line 100."

Text objects are where a lot of the power is at. They introduce more objects with prepositions.

Vap

This means "select around the current paragraph", that is select the current paragraph and the blank line following it.

V2ap

This means "select around the current paragraph and the next paragraph."

}V-2ap

This means "go to the end of the current paragraph and then visually select it and the preceding paragraph."

Understanding Vim as a language will help you to get the best mileage out of it.

After you have selecting down, then you can combine with other commands:

Vapd

With the above command, you can select around a paragraph and delete it. Change the d to a y to copy or to a c to change or to a p to paste over.

Once you get the hang of how all these commands work together, then you will eventually not need to visually select anything. Instead of visually selecting and then deleting a paragraph, you can just delete the paragraph with the dap command.

Daniel Kobe ,Apr 24, 2017 at 18:17

My vim gives me the error Not an editor command: VDaniel Kobe Apr 24 '17 at 18:17

kzh ,Apr 24, 2017 at 19:43

@Daniel vimdoc.sourceforge.net/htmldoc/visual.html#Vkzh Apr 24 '17 at 19:43

michaelmichael ,Sep 13, 2011 at 18:58

v35G will select everything from the cursor up to line 35.

v puts you in select mode, 35 specifies the line number that you want to G go to.

You could also use v} which will select everything up to the beginning of the next paragraph.

mateusz.fiolka ,Sep 13, 2011 at 18:58

For selecting number of lines:

shift+v 9j - select 10 lines

Peter Rincker ,Sep 13, 2011 at 19:38

For small ranges this is good, especially when paired with :set rnuPeter Rincker Sep 13 '11 at 19:38

µBio ,Sep 13, 2011 at 18:55

v 35 j

text added for 30 character minimum

Peng Zhang ,Feb 17, 2016 at 3:28

Shift+V n j or Shift+V n k

This selects the current line and the next/previous n lines. I find it very useful.

Kevin Yue ,Sep 24, 2016 at 5:20

It's very useful, thanks. – Kevin Yue Sep 24 '16 at 5:20

Arsal ,Apr 24, 2017 at 20:09

This is a simple way I was looking for. Thanks – Arsal Apr 24 '17 at 20:09

> ,

Text objects: http://vim.wikia.com/wiki/Creating_new_text_objects

http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

[Oct 22, 2018] move selection to a separate file Published on Oct 22, 2018 | superuser.com

Sites

Learn to love the Vim text editor - YouTube see min for interesting usage

Editing With vim 06 - Yanking, Cutting, and Pasting - YouTube -- good tutorial by BrandonioProductions

Editing With vim 01 - Installation, Setup, and The Modes - YouTube (all 14 videos)

Registers

Copying and Pasting with Vim - YouTube

Copy and Paste to-from Vim from-to Other Programs! - YouTube

Copy and Paste to-from Vim from-to Other Programs! - YouTube

Openwest 2015 - Erik Falor - From Vim Muggle to Wizard in 10 Easy Steps (8) - YouTube

Tip 386 Printable Monobook Previous Next



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: February 19, 2020