# Tag Info

5

You could do, DJx D -> delete rest of the line J -> join the next line x -> delete the space added by join

4

This is happening because Vim's HTML syntax will use style htmlHead to the text within the <head> block and it will link it to syntax group PreProc. (The PreProc group is meant for pre-processor directives, such as #include or #define in C/C++.) The slate colorscheme uses a white background (guibg=white) for the PreProc group, so it ends up styling ...

4

See the last command mentioned here :h shift-left-right :[range]> {count} [flags] So for your example :40> 21 Alternatively, if you don't want to do any arithmetic in your head: :40,60>

4

" tell which cinoption take effect for current line com! WhichCinoption call s:which_cinoption() function s:which_cinoption() abort " test if cindent take effect if !empty(&indentexpr) echo "'indentexpr' exists, it overrides 'cindent'." return endif if !&cindent echo "'cindent' is currently disabled." return endif " ...

4

A working, hacky solution function! Visual_indent_with_space() range abort '<,'>g/./exe "normal! " v:count1 . "I " endfunction vnoremap <leader><space> :call Visual_indent_with_space()<cr> Breaking down: '<,'>g/./exe "normal! " v:count1 . "I " '<,'>: use the selected range g/./: ...

4

You can align statements following the case label with the =N member of 'cinoptions'. The following will fix your specific example: :set cinoptions+==0 Unfortunately, it breaks indentation if you don't use a block: switch(x) { case a: { y(); } case b: y(); } You've indicated in the comments that this solution works for you, ...

3

After I did gg=G for the buffer with set ft=sh I get: while getopts 'dgSsx' opt; do case $opt in d) DEBUG=true ;; g) USE_GDB=true ;; S) USE_GEB=TRUE SMALL=true ;; s) SMALL=true ;; x) XFT=true ;; ?) for line in \ '-d enable debugging with verbose log output' \ '-g enable debug ... 3 There are too many such options to be able to answer this quesion in a general manner. However, they are mostly programming-languages oriented or exotic ones. In case of a "text document", such as markdown, you likely have to deal with only autoindent (an alternative is smartindent, as si is sometimes set default in some vimrc's, but si is a sort of "... 3 As of Vim 8.2.0139, there are no configuration options to specify this behaviour. Furthermore, any changes to the behaviour of Vim's soft wrapping via 'wrap' will require implementing in the source code: there is no workaround possible by using Vimscript.* See the feature request that Ryan Lue (who asked this question) added to the Vim project's issue ... 3 A solution I discovered while answering a duplicate: it should be faster than the existing answer, as it uses just a couple of matches/builtin functions, rather than looping over lines. The algorithm is simpler, too. However, it may not work if there are blank lines or comments between the { and the case, or comments at the front of those lines—I would ... 3 The basics of simple mappings are explained in Vim's excellent user manual at :help 05.4. You want some key combination (Shift + Tab) to do what's already provided by Vim's Ctrl + D command, so you map <S-Tab> (using :help key-notation now) to <C-d>. As Vim is a mode-based editor, you need to consider the mode; :help i_CTRL-D is for insert mode. ... 3 The command ]p does almost what you want, except it is not guaranteed to be linewise. In tpope/vim-unimpaired plugin it's already remapped to work linewise only, so if you use it (which I suggest anyway), you get it for free. Otherwise, you can implement the same trick yourself: nnoremap <silent>]p :call <SID>putline("]p")<CR> function ... 3 All "long" jump commands, such as gg, automatically save the bookmark for the previous poisition (note that G here is a "motion", so it does not overwrite the bookmark again), so all you have to do is to go back by that bookmark with two backticks: nnoremap <leader>= gg=G Or you can use CTRLO and CTRLI to navigate through the jumplist (:h jumplist) ... 3 In the absence of a complete solution, I thought I'd just write a quick answer that shows one way you can achieve the first part of your question. Try the following mapping (for F3): nnoremap <F3> :s/%>%/&\r/g<CR>Vj=gv>> How it works Splitting the line First, it breaks the line on the pipes: :s/%>%/&\r/g :s/ #... 3 You can reproduce this behavior in stock Vim with no extra plug-ins. The reason why this issue happens is that 'indentkeys' includes 0#, which triggers automatic reindentation of a line when you type # as the first character of the line. (Note that this is mostly meant for the C/C++ language, for directives such as #define or #include which are meant to ... 2 The easiest way is to change the keystrokes you use to start editing an empty line from a to cc. This allows the built-in cindent indentation to correctly adjust the indent when you enter insert mode, which it doesn't do when you specify that you want to append to the existing (blank) line. Note that this will only work if cindent is actually switched on. ... 2 This works with the options formatoptions and comments. Create the file .vim/after/ftplugin/rst.vim and add the following lines: setlocal comments+=b:- setlocal formatoptions+=ro For comments, the b:- adds the the dash as a comment character that has to be followed by a blank. See :help 'comments' and :help format-comments For formatoptions, the r ... 2 @dedoswdi's answer was extremely helpful! I adapted it somewhat to produce the result for each line on the buffer. My adapted script can be found in this Gist. After applying it to the original C++ code, I got the results with both cinoptions= (none of them set) and cinoptions=N-s (which triggers the odd behavior with the second struct.) Here are the ... 2 This is :h cino-+. It looks like get_c_indent() (from src/cindent.c) doesn't know about template and treats it like an ordinary expression split over several lines (here namespace serves as "a function" from :h cino-+). The relevant piece of code from src/cindent.c is 2831 else if (lookfor == LOOKFOR_UNTERM) 2832 { 2833 if (cont_amount > 0) 2834 ... 2 With the help of this, this, and this, I come up with this: nnoremap >> 0i<tab><esc>^ nnoremap << :norm 0ldF<tab><enter>^ For multiline selection (works on VISUAL, VISUAL BLOCK and VISUAL LINE): vnoremap > :norm 0i<tab><enter>gv vnoremap < :norm 0ldF<tab><enter>gv Put them on your ~/.vimrc.... 2 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 works much better than vim/neovim plugins. 2 This behavior is being enabled by the custom indentation function for the tex filetype. You can configure the behavior of that function, by setting some variables in your vimrc. For your specific case, to disable indentation after braces, you can use: let g:tex_indent_brace = 0 The tex indentation also indents \item elements in a special way, which you ... 2 the best I could come up with is using visual mode: v, j, h, d h is needed, because you've set selection=inclusive (this is default). To make the selection behave like in a majority of other text editors use set selection=exclusive. Next, if you want shift+arrow to start the selection you should set keymodel=startsel. Also, "delete" normally works the ... 2 Indentation of C/C++ code is typically done by enabling the 'cindent' option (built-in to Vim), which is in turn controlled by options set in 'cinoptions'. There are two interesting settings in 'cinoptions' that somewhat do what you want. The first is :set cinoptions==0, which instructs Vim to not indent the block under a case statement. So you do get this ... 2 I put together a little function that defaults to using cindent() for the indent, unless we are indenting a { line that directly follows a case statement (I've been twiddling a lot with indentexpr lately): function s:indent(lnum, offset) abort return a:lnum <= 0 \ ? indent('.') \ : indent(a:lnum) + a:offset endfunction function! c#... 2 I'd say the easiest way to insert text at the correct indentation is to use the o or O Normal-mode commands. From :help o: When 'autoindent' is on, the indent for a new line is obtained from the previous line. When 'smartindent' or 'cindent' is on, the indent for a line is automatically adjusted for C programs. Of course, these two commands will insert ... 1 I don't have a personal vimrc. Then Vim sources$VIMRUNTIME/defaults.vim You can see this by issuing :scriptnames Why are the last 2 lines in my vimrc ignored? They are not. The last line gets effectively cancelled by the line filetype plugin indent on from defaults.vim, because it gets sourced after it. The last 2 lines are: This is a huge mistake, ...

1

I have this since 2002 it seems It also handles <end> key inoremap <silent> <Home> <c-o>@=<SID>HomeLikeVCpp()<cr> nnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> vnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> inoremap <silent> <End> <c-\><c-n>...

1

Yes, it is possible to create a mapping for that. For example, a mapping that will go to the indent if you're elsewhere in the line, but go to the first character if you're on the indent: noremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ? "\<Home>" : "^" inoremap <expr> <Home> col('.') == match(getline('.'), '\...

1

I think the setting set smartindent has the behavior you want. If you use the following .vimrc on a.js, then you can see what's happening when you create a new line and press <cr> in normal mode while the cursor is over the indentation section of the new line. I'm using the setting set list to make ends of lines visible (as \$) and tabs visible (as ^I)...

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