New answers tagged

1

To get a list of marks in vimscript just use the following command: :marks I would also recommend the plugin called: vim-signature. This plugin will automatically display marks in vim. Here is a screen shot:


1

The :execute command will assemble an Ex command from strings and evaluate it. Here, in this case, it's actually breaking your command, since it's expanding the g:projectRoot string and forming a string that is an invalid Ex command, since the quotes around the path are now missing. That command is actually equivalent to: let ProRoot=/mnt/hgfs/projects/...


0

@LucHermitte provided the answer I was looking for. Quickcheck has a filetype = qf. Thank you! -E


0

:set cursorbind! works. Now the issue is that this option is local to the window and needs to be done into several windows in order to see any result. Moreover, it binds line numbers and not cursor positions. A mapping could be nnoremap <silent> <leader>whatever :<c-u>set cursorbind!<cr>:set cursorbind?<cr>


0

You can use a function for it: function! ToggleCursorbind() if &cursorbind == 1 set nocursorbind else set cursorbind endif endfunc And then make a mapping using your function: nnoremap <leader>c :call ToggleCursorbind()<CR>


0

The following function emulates the behaviour of: i + insert text + Esc. " Insert text at the current cursor position. function! InsertText(text) let cur_line_num = line('.') let cur_col_num = col('.') let orig_line = getline('.') let modified_line = \ strpart(orig_line, 0, cur_col_num - 1) \ . a:text \ . strpart(...


0

If you want the user to be able to enter a sequence such as r\<cr> or r\r and have Vim interpret that the same way as it interprets sequences in a double quoted string, the easiest way to do so is to actually assemble it into a double quoted string and use eval() to have Vim interpret it. In your particular case: execute "normal! " . eval('&...


3

Visual block mode (which you can enter with CTRL-V) is perfect for this kind of usage. You can copy and paste squares much like your router boxes and you can do so without shifting columns. Here is an example working with your initial diagram. Start by using a visual selection to copy the first router on the top left corner. First move to the upper left +, ...


2

Unfortunately, I don't see how as Vim provides no way to override the behaviour of assignment or of coercion (C++ way) or the "equivalent" we have in Python behind property. At best we can define a :PropSet command that forwards the assignment through the setter. But I don't see any simple way to handle situations where we need to evaluate ...


1

If we just limit to 1 aspect and we map it (instead of all user changes as question asks, and for vimscript instead of map), we can save-set-doStuff-reset easily: let str_zzz="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget libero quis mi gravida sollicitudin sit amet in sem." nnoremap <buffer> <leader>zzz \ :...


1

To extend the syntax for the tex filetype, you should specify your customizations in ~/.vim/after/syntax/tex.vim (or .config/nvim/after/syntax/tex.vim for neovim). The rules that you are looking for are quite complex, because they need to define nested regions. You would need to add the contains= keyword, something like this: syntax region texRefZone \ ...


1

You can normally use double quoted strings for this purpose. They accept a range of backslash escape sequences to produce special characters without having to input the special character literals into your buffer. The character that shows as ^M is the carriage return and you can enter it as "\r". You can also use key names in double quoted ...


0

One solution I found is to modify clang-format.py to catch the error if the file is not found on disk. The downside of that is that I need to keep my own copy clang-format.py, so if there's a fix in vimrc that is probably still preferable. But in case anyone has the same question in the future, here's the workaround I'm using in clang-format.py file: diff --...


0

You asked to check the variable in the mapping but I'm going to suggest an alternative approach that will make things a lot easier and give you more flexibility if you want to change anything later. Since you are using a function anyways my advice is to put everything in there. That simplifies things and avoids some issues you might have with escaping ...


1

Ok I solved in this way: function Commenta() let curline = getline(line('.')) let primo = strpart(curline, 0, 1) if primo=="#" :s/^#//g else :s/^/#/g endif endfunction


1

There are Vim plug-ins that emulate the "multiple cursors" feature from other editors such as Sublime or VS Code, for example, mg979/vim-visual-multi (successor to the now deprecated terryma/vim-multiple-cursors.) But since these plug-ins need to use Vim highlighting features to emulate multiple selections and they typically need to re-implement ...


6

I’m assuming all the things to change are the same. If not, I would probably proceed with either multiples of the steps below, or combine all the patterns into a single substitute pattern. So, not really what you asked for, but: *cgn Breakdown: *: start a search for the word under the cursor (g* if you don’t want the word boundaries) cchange gn the next ...


2

One way would be to press * when your cursor is on the word you want to replace, phrase in this case, which will search for that word (very useful in general!) It will use \<phrase\> as the pattern: the \> are word boundaries (similar to \b in Perl-style regexps) so that it won't match phrases. You can then use :%s//sentence/g; to replace phrase ...


Top 50 recent answers are included