Questions tagged [alignment]
Alignment is the organization of content elements by tokens/symbols and/or by column or line locations.
52
questions
1
vote
1
answer
62
views
change behaviour of > / < and >> / << to insert / remove only leading tabs
i want > / < and >> / << to simply insert and remove tab characters at the beginning of the line.
variant: i would even prefer to have> / < and >>/ << insert / ...
1
vote
0
answers
42
views
Expand all non-leading tabs but keep leading tabs [duplicate]
I want to use tabs for indentation and spaces for alignment in the following way:
keep tab characters (like noexpandtab) for all leading tabs of a file, but
expand tabs (like expandtab) that occur ...
0
votes
0
answers
63
views
Vim doesn't keep keep the same indentation as the line above it only in one situation
fn main {
scores.entry(team_1_name)
.and_modify(|&mut team| {
team.goals_scored += team_1_score;
team.goals_conceded += team_2_score;
})
}
When I press ...
0
votes
0
answers
191
views
Advanced plain text tables in Vim
What is the best way to create and edit tables in Vim, with a particular focus on 3 use cases: colspan, rowspan and multiline cells? Below is an example of the kind of table I would like to generate ...
1
vote
1
answer
679
views
Aligning variables and comments in vim
I've looked for this since a long time but I can't seem to find anything relating to this. It could be because of my poor searching skills.
Whenever the code starts getting long, its obvious that we ...
0
votes
1
answer
57
views
How to position cursor at a particular column (beyond the end of the line)?
Given this:
2022-07-28 Gå tur med Marvin
motion:rolig ...
motion:intens .
2022-07-29
motion:rolig ...
motion:intens ...
0
votes
0
answers
47
views
How can I align chained methods in Ruby files?
I often use = to indent lines but my configuration doesn't fit my needs.
Is there an option that indent lines like this:
'vim rocks'.capitalize
.concat(' !')
Instead of this:
'vim rocks'....
1
vote
2
answers
157
views
Tab to align cursor with next non-whitespace character in the line above (in insert mode)
How can we do this with vim?
set hlsearch " Highlight search matches
set incsearch " Highlight search matches as you type
set visualbell ...
1
vote
1
answer
675
views
How to get indentation lines for spaces without loosing chars like quotes in json files
rephrased my question based on Matt's answer and Christian's comment:
I really like the indentLine plugin that shows vertical lines to visualize indentation levels. However, when using it, it does not ...
1
vote
0
answers
129
views
Align c++ struct members using vim without plugins [duplicate]
Here is a code snippet of c++ source,
struct Random
{
int var1;
double var2;
unsinged int var3;
long long int var4;
}
The actual list of struct member I have is very large (over 50 ...
1
vote
0
answers
24
views
How to align only visually without changing the underlying code?
How can I set vim to only visually align assignments without actually changing the underlying code? Or is there a plugin which can do so?
Input:
int c = 8;
int result = 123;
Visualization:
int c ...
1
vote
1
answer
108
views
Reformat code: breaking lines and aligning on a character
I am writing code in R, specifically using the Tidyverse packages. There is extensive use of the pipe %>% to chain functions together. The lines become long, so it is recommended to break them up ...
14
votes
3
answers
3k
views
Align a block of code on the basis of a single character
The question's title might sound a little vague, so I'll explain the situation here more clearly.
I have these lines of code in a file which I want to align with respect to the character =.
const ...
0
votes
1
answer
119
views
How to view document as right-aligned without modifying it
I have a log file in which some lines are just a few characters while other lines are about a thousand. Is there a way to view the ends of each line without modifying the file?
I have two sub-optimal ...
0
votes
3
answers
294
views
Substitute tabs for equivalent number of spaces
N.B I use the word blank here due to lack of a better word. By blank I mean the remaining part of a tab that is visualized after the starting part. Please feel free to edit this question.
I know ...
3
votes
1
answer
518
views
How can I get Tabular to only work with certain lines and to use spaces as a delimiter?
How can I get Tabular.vim to only consider and affect lines that match /^item\s/, to use /\s\+/ as the delimiter, to left-align everything, and to use at least three spaces between words?
For example:...
2
votes
3
answers
1k
views
Working with line continuations (\).
When working in the C language, sometimes you have to write multi line macros like the following.
#define SOME_FUNCTION_LIKE_MACRO(a,b) \
foo(a); \
bar(b); ...
0
votes
1
answer
273
views
Align Righthand Side Comments
I have a bunch of assembly code that needs commenting and I want to avoid having to space forward to make a comment every time just to align the comments.
movq %rdi, %rdi # comment
jne label ...
-1
votes
1
answer
36
views
EasyAlign: Why first line is not aligned?
I have below shortcut and function to align code.
map <leader>vga :call Vhdl_GA_All()<CR>
" Alignment
function! Vhdl_GA_All()
exe ":'<,'> EasyAlign *<space>"
exe ":'<...
4
votes
1
answer
708
views
vim-easy-align: How to align multiple characters with single command?
I've created several keys and each key is working fine.
Want to find a way to do multiple alignments with single command. Like to create a key mapping, when it's running it can align the specific ...
1
vote
1
answer
47
views
How can I align the comment at the end of sentences when the comment predictor is already shown?
I want to align commens on multiple lines neatly, and found the following question and answer (I used the tabular package), but then I found out that it needs the comment specifier NOT to be shown on ...
1
vote
1
answer
197
views
How can I adjust ='s alignment of C-style comments?
I'd like = to indent block C-style comments like this:
/*
Comment.
*/
not this:
/*
Comment.
*/
Note the extra space before the last *. (I would like to automatically align the first / and the ...
1
vote
2
answers
219
views
How can I center align a word(s) in a table?
Say I have the table:
| TITLE |
| This is some text |
Can I center align the TITLE like so?
| TITLE |
| This is some text |
I've tried using both EasyAlign and Tabular but ...
7
votes
2
answers
597
views
Is it possible to align the results in the quickfix list in columns
Currently, when I view the quickfix list with :cw, the columns/pipes are not aligned, as in this example:
I wonder if there is an option in vim or a plugin to rearrange the pipes so that they align ...
1
vote
3
answers
822
views
simple map to right align text selection within visual block?
This should be easy but it seems to be a blind spot in vim. I'm looking for a short one line mapping, let's say to <leader>r, to right-align text inside a visual block selection. For example, ...
2
votes
1
answer
580
views
How can I right-align end-of-line comments with the Tabular plugin?
I often have code that looks something like this:
a = 1 # description 1
longer_name = 2 # description 2
# no_longer_needed = 3 # ignore
another_name = 4 # description 4
and would like to right-align ...
6
votes
3
answers
1k
views
align/spread file content in vertically split windows
I have a single buffer open across multiple vertically split windows and all the windows have scrollbind set. However, before setting scrollbind, I had to scroll down in second window in order to make ...
4
votes
2
answers
2k
views
How can I add a visual margin on the right of my window?
Here is my document; the entire text is on a single line:
However, I would like it to be not so wide; for example by using set textwidth=40 and gq I get my desired results:
The problem with this is ...
5
votes
1
answer
2k
views
How to sort lines by the right most characters?
When I enter visual mode, :'<,'>sort allows me to sort alphabetically the lines I have selected, obviously starting from the left most characters on a line going to the right.
Is it possible to ...
3
votes
2
answers
108
views
How to move word under current cursor to begin at current cursor?
My cursor is on the f of the first line. I'd like to move the word so that it aligns with the word below it. I know I could b i spaces until they align. I'd like to avoid getting in insert mode.
2
votes
3
answers
1k
views
Vim-easy-align: how to align delimeter on right
Fo example, this piece of code in rails:
t.string :receipt_number
t.timestamp :transaction_timestamp
t.string :transaction_type
t.decimal :cash_amount
t.decimal :card_amount
Now, I want ...
4
votes
1
answer
375
views
Align code functions documentation
Is there an easy way to align a function documentation (I'm using Python) from this:
arg1 :: Some text
arg2345 :: Some very long text text text text
arg3:: Other text
to something like:
arg1 ::...
6
votes
4
answers
5k
views
How to add space around a symbol using vim?
I have following code. I want to add spaces around =. With the minimal keystrokes (May be with the help of macro). Do not want search and replace approach.
<div className="row">
<div ...
5
votes
1
answer
462
views
How to align statements around a particular word or token?
I want to align my statements around a particular word or token.
Example:
import React from 'react';
import { browserHistory, Router, Route } from 'react-router';
import Main from ...
1
vote
1
answer
110
views
perl multi line comments are not aligned properly
With Vim 7.2, when a perl block is aligned using =,
Multi line comments are moved as per the blocks inner alignment. But they should be placed at immediate start of the line.
Is there any way to ...
3
votes
1
answer
466
views
Align C preprocessor definitions
How do I align C preprocessor definitions using vim's Align plugin?
Something like:
#define ORING 'r'
#define OLRING "ring"
where the string 'r' should be aligned with "ring".
I don't find any ...
0
votes
1
answer
80
views
Using Align plugin
I want to align C variables declariations with the Align plugin using \adec as parameter, the problem is that it doesn't do anything.
struct mutex {
pthread_mutex_t listmsg;
pthread_rwlock_t ...
5
votes
3
answers
852
views
How can I replace a word in a column without changing the width
I'm writing cucumber example tables, which are formatted like this:
| title | title |
| data | data |
| data | data |
How can I replace one of the data or title cells with a word of ...
10
votes
1
answer
2k
views
How do I align C++ comments to be compliant with Google styling?
Any way to get Vim to format my comments to comply with Google cpplint?
Top section is not compliant, to comply 5 changes are required.
keep this comment at the same level
Add a space after //
add ...
7
votes
1
answer
2k
views
Neovim format ruby code like rubocop
is there any chance to format code to satisfy rubocop?
By default my neovim is indenting code like that:
class Test
attr_accessor :a, :b, :c,
:d, :e, :f
end
However, it would be nicer to have ...
5
votes
1
answer
577
views
A plugin to align comments
I often edit code where I have a general comment for a block of code and specific comment for each line. For instance, this a sample of my .vimrc.
"indentation
set autoindent "...
5
votes
0
answers
194
views
How to align a Latex table that uses \multicolumn?
I want to align a Latex table the way it appears in the final document.
There are various Vim plugins for aligning tables (2, 3, 4), but none of them handle the spanning cell correctly. The code ...
3
votes
1
answer
614
views
easy-align spaces around delimiters
I'm using vim-easy-align plugin and when in bash scripts I try to align $ at the beginning of variable names, the aligning adds spaces around the delimiter, i.e. <space>$<space> which of ...
5
votes
1
answer
243
views
Is there a way to push existing text left while inserting (e.g., insert right-aligned text)?
In insert mode, typing normally moves the cursor right and pushes text to the right of the cursor farther to the right on the line. I am typing some right-aligned text and am wondering - is there a ...
1
vote
0
answers
77
views
How do I make Vim highlight a margin? [duplicate]
I want to make Vim highlight the entire margin past column 79. I've seen other people's editors have a nice indicator bar or margin for maximum line length. What do I add to my config?
69
votes
6
answers
72k
views
How to add indentation guides/lines?
In Sublime Text 2, you get vertical guides where your indentation is, like this:
but Vim doesn't:
Is there a way to show lines like that in Vim?
By the way, my indentation is 2 spaces.
:set tabstop=...
16
votes
7
answers
6k
views
How to left-align two columns of text? [duplicate]
If I have a text file like this:
alpha: 1
beta: 2
gamma: 3
delta: 4
epsilon: 5
Is there a way to align the numbers like so?:
alpha: 1
beta: 2
gamma: 3
delta: 4
epsilon: 5
7
votes
2
answers
2k
views
Creating & maintaining flowcharts in Vim
Here is a simple text-based flowchart I made in Vim for a weblog post:
[DNS request]
|
|
[Adsuck]
|
...
45
votes
6
answers
22k
views
Can I justify text in Vim?
The only reason why I'd ever edit a text file in Pico or Nano, and not in Vim was its "Justify" command ^J. It would reformat a paragraph of text, creating line breaks at word breaks so that the text ...
15
votes
4
answers
4k
views
Adding 80-column wide comment header block with centered text
For some reason or another I often divide the code into subsections separated by headers like these:
################################################################################
##################...