New answers tagged

1

Since i$ is a mapping itself (defined by the vimtex plug-in), you need a recursive mapping to be able to use i$ as part of the expansion of your mapping. So this should work: nmap cim ci$ But you can also create an operator-pending mode mapping for im, in which case that would work with other operations such as dim or yim and other built-in or custom ...


1

Just add the same mapping in Visual mode as well: nnoremap <space>d "_d xnoremap <space>d "_d You can also use a simple noremap, which maps in Normal, Visual and Selection mode, just in that case you might want to undo the mapping in Selection mode (which is probably inappropriate for that mode): noremap <space>d "_d sunmap <space>...


2

In general, :unmap <C-x> can get rid of he mapping (note the variants like :nunmap, etc.). However, it is strange that the mapping persists without being in your .vimrc. You can use :verbose map <C-x> to see where the mapping is coming from.


4

Andrew Radev's splitjoin plugin is designed specifically for this (and many similar) use cases. After installation, simply place your cursor on the first line and type gJ to convert from a multiple assignments to a single one. If you need to go in the other direction, you can type gS on a single-line multiple assignment.


3

In terms of keystroke efficiency, it's hard to beat a recorded macro. Starting with your cursor on the first self., typing the following will create a macro in your "q register which add the next line that begins with self. to the current assignment: Emaqq/^self\.<CR>d3ei <Esc>`aa, <Esc>pma``d2wywdd`aA, <Esc>"0pq You can then ...


3

There might be plug-ins that do this particular transformation, or you might be able to use two fairly long :s/// commands to isolate each side. But personally I find that using Vim's Visual Block feature is the best way to handle column data, which is the main kind of transformation you have here. You can start by aligning the =s so you really have three ...


3

I'm not sure this is what you want, but you could try these global commands: g/^self\./,/^\(self\.\)\@!/-j g/^self\./let l=[]|s/\s*=\s*\(\w*\)/\=add(l,submatch(1))[-1][-1]/g|s/\s/, /g|s/$/\=' = '.join(l,', ') The first command should turn this block: self.mat = material self.epsilon=epsilon self.x = x into this line: self.mat = material self.epsilon=...


3

Try overriding the default za functionality with this mapping: :nnoremap <expr> za foldclosed(".") == -1 ? 'zc' : 'zv' It uses the foldclosed() function within an expression mapping to check if the cursor is on a closed fold, mapping to zc if it's not, and zv if it is.


1

Try nmap <leader>cv <leader>ca<leader>cc<leader>ca Note that you can't use nore-stuff here.


1

It sounds as though the supertab plugin has either overwritten or removed your insert mode mapping. You can check if this is the case with the command: :verbose imap <C-X> You can reinstate your mapping simply by re-running your map command again: :inoremap <C-X> <BS> The best way to do this automatically in your vim configuration is ...


0

nnoremap <C-I> <C-I> vnoremap <Tab> <Esc>gV onoremap <Tab> <Esc> inoremap <Tab> <Esc>`^ I remap tab to exit. I think historically that's where the esc key used to be, so I used it and never looked back. I hardly ever need to put in a tab in a document, and when I do I just press shift + tab. I have never once ...


1

You should simply remove that undo file, it's unlikely you'll manage to get something useful from it. You can actually trim the undo history by setting 'undolevels' (see also :help clear-undo), but when you do so, the newer changes are preserved and the older ones are purged. If the newer changes are the problematic ones, trimming them means trimming the ...


1

No need to embed commands in the split. You can use multiple commands in a single mapping. nnoremap <leader>n :15sp $HOME/_notes/n0w<cr>Go After the split command is submitted with <cr>, this being nmap we can just specify Normal mode commands. Specifically, G for step (iii) (go to end of file) and o for steps (iv) and (v) (add a new line ...


5

I screwed up slightly on which :verbose map to use. Since it's while editing, and the relevant mapping is imap or inoremap, :verbose imap/:verbose map! would be the right command. In this case, the reason I had such weird behavior is because of the function it's mapped to. It calls a function in a parentheses auto-completion/utility library, and ...


Top 50 recent answers are included