SergioAraujo
  • Member for 5 years, 9 months
  • Last seen this week
How to make regex matchers non-greedy?
18 votes

I prefer always breaking the problem into two steps: /\v(https?):\/\/(.{-})\/.* <-- Search :%s,,Protocol:\1 - Domain:\2,g <-- Substitution Using very magic "\v" to avoid many ...

View answer
Quickly calculate the total of a column of numbers
12 votes

:r!awk '{sum+=$6} END {print "Total: "sum}' % Explanation: :r ........... read (put result in this file) ! ............ external command awk .......... external tool {sum+=$6} .... sixth field (awk ...

View answer
How do I reverse a string with Vim script
5 votes

From wikia vnoremap <Leader>r c<C-O>:set revins<CR><C-R>"<Esc>:set norevins<CR> For more see: :h revins

View answer
How to restore the position of the cursor after executing a normal command?
4 votes

This function keeps also your search register. So you can pass your command as argument on it. if !exists('*Preserve') function! Preserve(command) try " Preparation: save last ...

View answer
What is a scratch window?
3 votes

I have created a "Scratch" command command! Scratch new | setlocal bt=nofile bh=wipe nobl noswapfile nu

View answer
Jedi module is not found (deoplete)
Accepted answer
3 votes

In my case I had to run this command: pip3 install --user jedi

View answer
How to replace each match with incrementing counter?
3 votes

Just adding '#' at the end plus a counter 'c' :let c=0 | g/^#\d\+.*/ let c+=1 | s//\='#' . c The global part g/^#\d\+.*/ let c+=1 allow us to increment the counter only in the lines that have a ...

View answer
Write selected area to file
3 votes

You can also copy your content and create a new window Ctrl-w n ........... create a new window p .................. paste Then you can save as you want

View answer
Reverse a set of paragraphs
3 votes

Another one line solution: :$put _ | g/Example [2-4]/normal! dapggP One line solution: :$pu _ | 16,20m0 | 16,20m5 | 16,20m10 I have thought a lot until reach this elegant solution (one-liner above)...

View answer
short key mapping by lua for neovim
2 votes

I have found a slightly different solution here: local function map(mode, lhs, rhs, opts) local options = {noremap = true} if opts then options = vim.tbl_extend('force', options, opts) end vim....

View answer
How to force vimtex to display \textbf and \textit in insert/normal mode?
2 votes

I think would be useful a "Toggle" mapping that allows us to swich concealling level: nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <...

View answer
How to exclude the ending pattern in a search range?
2 votes

My approach :g/group2/+1,/group3/-1p

View answer
Exit from Terminal mode in Neovim/Vim 8
1 votes

In my case (I use <leader>x, to close any buffer), as I have init.lua instead of init.vim my configs are: -- map helper local function map(mode, lhs, rhs, opts) local options = {noremap = ...

View answer
Quickest way to put a single piece of text in multiple lines
1 votes

Would you try this? :%s/: \zs/\=@+ If you want space after the comma set your clipboard register before running the above command: :let @+='text from some register, '

View answer
Substitute second occurence on line
1 votes

My attempt :%norm 4ftdwx :%norm ......... execute in normal mode over the whole file 4ft ............ the 4th t matches the start of the second temp dw ............. deletes the current word x ......

View answer
Merge blocks by interleaving lines
1 votes

I've just seen another similar question and the solution consists of: Jump to the middle plus one: Mj And run: :,$g/./exe 'm' 2*line('.')-line('$')-1

View answer
What is the use of the black hole register ("_)?
1 votes

One practical use in one function. In the bellow function the python comment # is added and removed depending on the result of getline('.')[0]. If the line has a comment the char # is deleted, but in ...

View answer
Automatically insert characters with Ultisnips upon exiting Insert mode
Accepted answer
1 votes

In my case I have found in plugged/vim-snippets/UltiSnips/all.snippets a snippet called box that makes something like that: ---------------------- - some text inside - ---------------------- After ...

View answer
How to reverse the order of lines?
1 votes

Using relative numbers. Paragraph starts at line 13 and spams more 4 lines :13,13+4g/^/m12

View answer
Is there a vim command line option to edit last edited file?
1 votes

Another solution (in normal mode) after opening vim/neovim Ctrl-o Ctrl-o

View answer
I don't understand the logic of recovering crashed edit files
0 votes

Maybe you would like to see this great plugin: - vim-autoswap

View answer
Analyze NeoVim Performance Bottlenecks
0 votes

One plugin that notably improved my neovim startup time is filetype.nvim the speed test measured 175x faster filetype detection for neovim. This plugin is a replacement for the included filetype.vim ...

View answer
Restoring cursor to position before delete after Undo
0 votes

Using lua api (nvim) we can do: line, col = unpack(vim.api.nvim_win_get_cursor(0)) vim.cmd [[ normal 4X]] vim.cmd [[ normal u]] vim.api.nvim_win_set_cursor({0}, {line , col}) The first line saves ...

View answer
In neovim, how can I share registers between editor instances?
0 votes

Sorry, because I dont know anymore where I found this: " share data between nvim instances (registers etc) augroup SHADA autocmd! autocmd CursorHold,TextYankPost,FocusGained,FocusLost * ...

View answer
Replace with hex character
0 votes

I figured it out a solution: :s/\%x19/ /g TIP: The value \x19 can be expressed on Unicode by \u0019. So you can do: :s/ /\="\u0019"/g When you press ga you can see the hex value, if it has less ...

View answer
How to get around this common multiple-cursors use case?
0 votes

Let's consider our cursor at the first line, column zero f' ....................... jumps to the first single quote Use visual block selection to cut the three first lines Ctrl-v ......................

View answer
Markdown in Neovim: which plugin sets conceallevel=2?
0 votes

Or create a Toggle mapping: nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <CR> I am using the abbreviated form of conceallevel ...

View answer
What's the simplest way to strip trailing whitespace from all lines in a file?
0 votes

Another version of the StripTrailingSpaces function: if !exists('*StripTrailingWhitespace') function! StripTrailingWhitespace() range if !&binary && &filetype != 'diff' ...

View answer
How can I copy text to the system clipboard from Vim?
0 votes

You can also use a global command to put some specific pattern on the clipboard. It can be useful in situations where you have information scattered in a file and manually coping is prone to errors ...

View answer
How to left-align two columns of text?
0 votes

My attemp to solve the issue vip ............... select paragraph :'<,'>!column -t align :%norm $X ......... remove one space

View answer