Skip to main content
Fixed the "Yank" command (little y)
Source Link

I just do column selection + copy for such unaligned movement of my code.

So... first I have expandtab (et) as part of my settings at the bottom of my file like so:

// vim: ts=4 sw=4 et

This means the tabstop is at 4 characters, the shiftwidth is also at 4 characters, and expandtab is also turned on (so no tabs anywhere, just spaces).

When I have a problem like yours above, so this code:

proj_object = self.session.query(Project) \
                        .filter(Project.id == parsed_proj.id) \
                        .one_or_none()

I go under the first line and select using Ctrl-V (column select), in this case go down once, do Yy to yank that column and then p to copy the column. I repeat the p until the alignment is correct (twice in your example).

Here is a screenshot showing the selection of the column:

enter image description here

As long as all the characters before the . are spaces, the Ctrl-V can happen at any location.

Note: when the selection is rather large, I use my mouse. Although it's possible to enter the column selection with the mouse, it require a quadruple click which I find annoying. However, with just one left click and selection, then Ctrl-V problem solved! You can actually use v and Ctrl-V any number of times to switch between the two selection modes (and V too [capital], which is used to select whole lines).

I just do column selection + copy for such unaligned movement of my code.

So... first I have expandtab (et) as part of my settings at the bottom of my file like so:

// vim: ts=4 sw=4 et

This means the tabstop is at 4 characters, the shiftwidth is also at 4 characters, and expandtab is also turned on (so no tabs anywhere, just spaces).

When I have a problem like yours above, so this code:

proj_object = self.session.query(Project) \
                        .filter(Project.id == parsed_proj.id) \
                        .one_or_none()

I go under the first line and select using Ctrl-V (column select), in this case go down once, do Y to yank that column and then p to copy the column. I repeat the p until the alignment is correct (twice in your example).

Here is a screenshot showing the selection of the column:

enter image description here

As long as all the characters before the . are spaces, the Ctrl-V can happen at any location.

Note: when the selection is rather large, I use my mouse. Although it's possible to enter the column selection with the mouse, it require a quadruple click which I find annoying. However, with just one left click and selection, then Ctrl-V problem solved! You can actually use v and Ctrl-V any number of times to switch between the two selection modes (and V too [capital], which is used to select whole lines).

I just do column selection + copy for such unaligned movement of my code.

So... first I have expandtab (et) as part of my settings at the bottom of my file like so:

// vim: ts=4 sw=4 et

This means the tabstop is at 4 characters, the shiftwidth is also at 4 characters, and expandtab is also turned on (so no tabs anywhere, just spaces).

When I have a problem like yours above, so this code:

proj_object = self.session.query(Project) \
                        .filter(Project.id == parsed_proj.id) \
                        .one_or_none()

I go under the first line and select using Ctrl-V (column select), in this case go down once, do y to yank that column and then p to copy the column. I repeat the p until the alignment is correct (twice in your example).

Here is a screenshot showing the selection of the column:

enter image description here

As long as all the characters before the . are spaces, the Ctrl-V can happen at any location.

Note: when the selection is rather large, I use my mouse. Although it's possible to enter the column selection with the mouse, it require a quadruple click which I find annoying. However, with just one left click and selection, then Ctrl-V problem solved! You can actually use v and Ctrl-V any number of times to switch between the two selection modes (and V too [capital], which is used to select whole lines).

Source Link

I just do column selection + copy for such unaligned movement of my code.

So... first I have expandtab (et) as part of my settings at the bottom of my file like so:

// vim: ts=4 sw=4 et

This means the tabstop is at 4 characters, the shiftwidth is also at 4 characters, and expandtab is also turned on (so no tabs anywhere, just spaces).

When I have a problem like yours above, so this code:

proj_object = self.session.query(Project) \
                        .filter(Project.id == parsed_proj.id) \
                        .one_or_none()

I go under the first line and select using Ctrl-V (column select), in this case go down once, do Y to yank that column and then p to copy the column. I repeat the p until the alignment is correct (twice in your example).

Here is a screenshot showing the selection of the column:

enter image description here

As long as all the characters before the . are spaces, the Ctrl-V can happen at any location.

Note: when the selection is rather large, I use my mouse. Although it's possible to enter the column selection with the mouse, it require a quadruple click which I find annoying. However, with just one left click and selection, then Ctrl-V problem solved! You can actually use v and Ctrl-V any number of times to switch between the two selection modes (and V too [capital], which is used to select whole lines).