55 votes

How to add indentation guides/lines?

Another option I use, which isn't exactly what you asked for, but accomplishes the same purpose of making it easier to see what is in the same column, is to set the following in your vimrc: set ...
Karl Bielefeldt's user avatar
14 votes
Accepted

Align a block of code on the basis of a single character

If you're in a pinch and want to get the expressions aligned, without having to install and learn any plug-ins, here is a quick way to do it. Select the lines on a visual selection. For example, if ...
filbranden's user avatar
  • 28.8k
12 votes

How can I easily create and maintain tables?

If you don't want to install any plugins and you want to edit tables keeping the alignment: -- use the built in VREPLACE mode, activated by gR. (Make sure you has vim latest version, and check if it's ...
rossijonas's user avatar
11 votes
Accepted

How do I align C++ comments to be compliant with Google styling?

clang-format is a command line tool that formats c++ code. One of the default formatters is google. clang-format -style=google There are plugins that would allow you to run clang-format in vim. One ...
FDinoff's user avatar
  • 2,046
10 votes
Accepted

How to sort lines by the right most characters?

If you can use the rev command, you could reverse each line, sort and reverse again, using external commands in a pipe: %!rev | sort | rev This can be done entirely in Vimscript, but it's way more ...
muru's user avatar
  • 24.9k
10 votes
Accepted

How to left-align two columns of text?

See accepted answer to Align a block of code on the basis of a single character To recap ggVG to select all :'<,'>normal f:5a you don't have to enter '<,'> and also note space at the end....
Maxim Kim's user avatar
  • 13.4k
8 votes
Accepted

How to align statements around a particular word or token?

The Tabular plugin works with regular expressions. So, you can give a word or a pattern, not just a single character. :Tabularize /from/ will align in the way you wanted. You can find a great ...
SibiCoder's user avatar
  • 3,372
6 votes

How can I easily create and maintain tables?

I've created the command-line tool tablign for this purpose; it works from within vim as well. Simply install with [sudo -H] pip3 install tablign mark the table in vim and call :'<,'>:!...
Nico Schlömer's user avatar
6 votes

How to add space around a symbol using vim?

I'm not sure why you don't want to use search/replace, but here's a reusable command: command! HTMLArgEq %s/\s\@<!=\+\s\@!/ \0 /g It uses search/replace, but you only need to create it once. ...
Tommy A's user avatar
  • 6,770
6 votes
Accepted

simple map to right align text selection within visual block?

Here's a simple mapping to do the task: vnoremap <silent> rs "zy:call setreg("z", system("echo \"" . @z . "\" \| sed 's/[ \\t]\\+//' \| rs -j 0 1"), "b")<CR>gv"zp It uses z register to ...
grodzik's user avatar
  • 4,588
5 votes
Accepted

How to move word under current cursor to begin at current cursor?

Without entering insert mode (not sure if it's better though): Example text (cursor on C of the first line): A BBCBB A BBCBB Type: bjywkP Decomposing: bj go back to the start of the word,...
nobe4's user avatar
  • 16k
5 votes

How to add space around a symbol using vim?

Here's what I would do. Visually select all of your HTML you want to do this to, and hit the following: :norm f=i<space><C-v><esc>la<space> Note that <C-v>, <esc>,...
DJMcMayhem's user avatar
  • 17.6k
5 votes
Accepted

Is it possible to align the results in the quickfix list in columns

Some more searching yielded the qf-layout plugin, which is working great in my initial tests! In order to show only the basename instead of the entire filepath, I modified line 84 from let l....
joelostblom's user avatar
5 votes

Is it possible to align the results in the quickfix list in columns

If your Vim includes the patch 8.2.0959, you can set the 'quickfixtextfunc' option to the name of a Vimscript function whose task is to format each entry displayed in the quickfix window. To get the ...
user938271's user avatar
  • 5,957
5 votes

Working with line continuations (\).

Plugin vim-lion by Tom McDonald Install and add following line to your vimrc: let g:lion_squeeze_spaces = 1 Now you can change #define SOME_FUNCTION_LIKE_MACRO(a,b) \ foo(a); ...
Hotschke's user avatar
  • 4,750
5 votes

Align a block of code on the basis of a single character

The answer provided by filbranden shows the sequence in general. Though, it is quite complicated. The most interesting part there is command normal. So, I would simplify and generalize the whole ...
Maxim V.'s user avatar
4 votes
Accepted

Align C preprocessor definitions

You can use :<range>Align \s which will use the white spaces as separators. It will give you the following: #define ORING 'r' #define OLRING "ring" To align only the part between the ...
statox's user avatar
  • 49.8k
4 votes

How to add indentation guides/lines?

Try the most recent updated of Goneovim, not the current release 0.4.6. It's not pure vim but a neovim gui, and it does not gain much attention. The indent guides feature of goneovim is native, and ...
duqu's user avatar
  • 41
4 votes

How to add indentation guides/lines?

The indentLine plugin tends to be fairly slow on non-small files, observable when clicking enter as it lags by a second or so. I've found vim-indentguides to be a faster and visually similar plugin, ...
jaybay's user avatar
  • 91
4 votes
Accepted

Align code functions documentation

Vim's comment formatting only handles comment characters that appear at the start of the line. However you could make use of the list formatting facility (:help 'formatlistpat') that kicks in when n ...
Antony's user avatar
  • 2,570
4 votes

Align a block of code on the basis of a single character

Install vim-easy-align, assume you bind <Plug>(EasyAlign) to ga, execute gaip=, done. This plugin comes with a lot of predefined rule to handle common align scenarios. Another way to do this is ...
dedowsdi's user avatar
  • 6,258
4 votes
Accepted

How to position cursor at a particular column (beyond the end of the line)?

You can put set virtualedit=all in your vimrc to allow cursor to be positioned anywhere, even where there are no chars, and then you can use the normal mode command 80| to move the cursor to the 80th ...
mattb's user avatar
  • 1,121
3 votes

How can I replace a word in a column without changing the width

If you were using Vim them you could use some alignment plugin, as mentioned on the question comments. Or you could use the vimwiki plugin, which provides several helpers to use tables. As you are ...
mMontu's user avatar
  • 6,630
3 votes

How can I set up a ruler at a specific column?

I mostly do coding in vim (version 7.4) and I have added the below two lines in my .vimrc to maintain a "colorcolumn" for 100 character length. :set colorcolumn=100 ...
hel's user avatar
  • 131
3 votes
Accepted

Using Align plugin

\adec is not a parameter to :Align, it is a key mapping. Don't type :Align \adec Just hit the keys \adec
joeytwiddle's user avatar
  • 3,622
3 votes

How to add space around a symbol using vim?

Search and replace can be used, but I must admit, the syntax is not simple to remember: :%s/\s*=\@<!==\@!\s*/ = /g The first \@<! matches with zero width if the preceding atom doesn't match = (...
Luc Hermitte's user avatar
  • 17.4k
3 votes
Accepted

How can I right-align end-of-line comments with the Tabular plugin?

Just figured this out and wanted to share with people. You can use :Tabularize /^\s*\S.*\zs# where the ^\s*\S.*\zs# is a vim regexp that matches only the last comment character, while ignoring ...
Luke Davis's user avatar
  • 1,397
3 votes

simple map to right align text selection within visual block?

What about doing the substitution on the visual selection with \%V, and avoiding external programs? For instance, the following does the job (I'll use \v to simplify the patterns): '<,'>s/\v%V(...
Luc Hermitte's user avatar
  • 17.4k
3 votes

How can I adjust ='s alignment of C-style comments?

You can adjust the indent of the end comment by setting the 'comments' option. e.g.: :set comments=s:/*,m:\ ,e-3:*/ This is documented at :help 'comments' and :help format-comments. You might also ...
Rich's user avatar
  • 31.9k

Only top scored, non community-wiki answers of a minimum length are eligible