46

I am the author of the plugin vim-table-mode. I've spent quite a lot of time building & improving this, especially with community feedback and it caters exactly to this use case. A short quickstart: You enter 'table mode' with the :TableModeEnable command, you can then simply type: || | MOVIE | QUOTE| || | Blade Runner | Like tears in the rain | | Monty ...


42

You can use the gq or gw operators combined with a motion command. By default, formatting of applicable text is done by Vim and to the best of my knowledge it does not justify the lines (you will get ragged right margins). Alternatively, an external program (e.g. the fmt command on Linux) can be used to do the formatting by specifying it with the formatprg ...


19

There is a great VimCast on this topic. http://vimcasts.org/episodes/formatting-text-with-par/ Basically, you need to install par: $ brew install par # or $ sudo apt-get install par And then, since you want columns to be wrapped in 80 columns: :set formatprg=par\ -w80 Now you can use the gq operator, like in other answers (e.g. gqip), and it will use ...


14

You should be able to add something like this to your vimrc: autocmd BufReadPost *.odt :%!odt2txt % That will send the entire buffer through the odt2txt program after it's read in by vim, but only if the file name ends with .odt. There's also the textutil.vim plugin that says it can do what you're talking about for a few of those file types (but I haven't ...


14

From :help usr_25: JUSTIFYING TEXT Vim has no built-in way of justifying text. However, there is a neat macro package that does the job. To use this package, execute the following command: :...


9

In the past I had similar problem with function signatures. Here is solution adapted to your problem. Add to .vimrc: au CursorMovedI *.md call ModifyTextWidth() " Use only within *.md files function! ModifyTextWidth() if getline(".")=~'^.*\[.*\](.*)$' " If the line ends with Markdown link - set big value for textwidth setlocal textwidth=500 ...


7

Even simpler: the a flag for 'formatoptions' enables automatic formatting of paragraphs whenever text is inserted or deleted. See :help fo-table for details on 'formatoptions' flags and :help autoformat. :set formatoptions+=a gq and gw will format the lines that the following motion moves over. Formatting is done with one of three methods: ...


7

I don't believe there is one built in, but you can map one yourself in your vimrc: inoremap <c-b> <esc>vBda


7

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 compiled with +vreplace feature, typing vim --version on the terminal) (my statusline is set to show REPLACE for both REPLACE and VREPLACE modes) If you ...


7

If you can use sed and column, a command-line solution that comes close would be: !sed 's/[- ]*\([+|]\)/'$'\x01''\1/g' | column -ts $'\x01' | sed '/^[-+ ]*$/s/ /-/g' You could combine this with visual selection and '<,'> or with line numbers. Cons: Uses sed and column. Vim is incidental. The sed commands can probably be changed to vim :substitute ...


6

While nano's help call the ^J command "Justify" it actually doesn't justify the text, it reformat the text breaking the lines before the right margin of the screen (or at some configurable column, I guess). You can do the same thing in VIM by setting the variable textwidth, from :help 'textwidth': Maximum width of text that is being inserted. A longer ...


6

TLDR: There is no such thing. Vim edits plain text, and there is no "italic mode" or anything like that. To be more specific: Vim is not a word processor. You are confusing file formats and how they render in typical WYSIWYG interfaces (like Microsoft Word) with a text editor, like Vim, Emacs, Notepad, etc. The latter, including Vim, only edits plain text ...


5

You could use the abolish plugin. For your example you could use the following: :Abolish perche{'} perché It changes perche' to perché, Perche' to Perché and PERCHE' to PERCHÉ. For the second example: :Abolish dopodiche{'} dopodiché


4

The following script provides the :Ambiguous command. It displays keywords (read :h 'iskeyword') that are the same but have different letter case in the location-list window. The script is explained through its comments: function! s:display_ambiguous() abort let buckets = {} " Split all text in the buffer by non-keywords. for word in split(join(...


4

Does it have to be dictionary completion, triggered via i_CTRL-X_CTRL-K? If another trigger key is fine (e.g. i_CTRL-X_CTRL-@), you can do this: Save the 'dictionary' option value Change it to point to your tags file Install an :autocmd CompleteDone handler that resets the option value Trigger dictionary completion Alternative If you don't actually need ...


3

As far as I know there is no built-in method for this, but I extended g<C-g> using the following function: fun! s:readtime() let l:status = v:statusmsg try exe "silent normal! g\<C-g>" echo printf('%s; About %.0f minutes', \ v:statusmsg, ceil(wordcount()['words'] / 200.0)) finally let v:...


3

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 :'<,'>:!tablign (vim fills in the first few characters for you if you've marked the table.) It can't do fixed column widths yet, but that could be added if need arises.


3

Here are two easy options: with a block of text selected, type !fmt with your cursor at the start of a block, type !}fmt Both of these send a block of text to unix fmt, see man fmt for options. You can pass option arguments from vim. For example, to format a block a 50 characters wide, type !}fmt -w 50.


3

I also use vim for a lot of word processing/prose, and I format as I go, rather than having a catch-all command that formats all your text at once. By manually formatting as I go, I implicitly solve the problem you describe. I'm not sure if this fits your workflow, but I'll describe it below: I use this mapping: " Easy line wrapping/formatting imap gq <...


2

@Ingo Karkat Your Txtfmt files should look the same on different computers. If they don't, it could be that Vim is using a different encoding on the different computers (e.g., utf-8 vs latin-1), and you haven't set Txtfmt's 'tokrange' option explicitly. Recommended approach is to set 'tokrange' to a value that will work on all your systems in a "Txtfmt ...


2

For the sake of completeness, I'd like to mention the plugin-based option. If you use something like ALE which supports running your buffers through a beautifier on save, you could let Prettier handle rewrapping your code. I accomplished that by putting this in ~/.vim/ftplugin/markdown.vim: let b:ale_fixers = ['prettier', 'remove_trailing_lines', '...


1

As the vim community did not have such a plugin I have then developed it. It is available at: https://github.com/fmv1992/vim_dictionary Features Works offline (downloads a dictionary during the install). Is asynchronous: one instance of the plugin launches a server which serves all your vim instances (memory efficient). Is simple: just one command is ...


1

Put your cursor on a word then do... :r http://services.aonaware.com/DictService/DictService.asmx/De‌​fine?word=<cword> | %s/<\_.\{-}>//g | %s/^M//g You'll want to do a little bit more sophisticated post-processing to remove the XML. :) I was just fooling around with this at first. It started as an exercise for myself to see how quickly I ...


1

I would have a look at :help 'textwidth'. It will automatically break lines as you type. However this doesn't work if you're editing the middle of a line. I personally prefer to leave textwidth off so I created a function that will auto join and split a paragraph. (Basically auto format it to 80 characters) It looks like this: function! ...


1

Have you tried any note taking plugin ? I use vim-notes for personal notes and I think it does its job very well.


1

It really depends on where you want to read those documents. Inside Vim, you can define your own syntax highlighting, and then have any sort of words or marked-up text highlighted according to Vim's capabilities. That makes it non-portable, though: You need to have your syntax script around. For a portable, no-install solution, you need an external viewer, ...


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