Naumann
  • Member for 4 years, 11 months
  • Last seen more than 2 years ago
How can I repeat last substitution and with the same flags
Accepted answer
13 votes

This is exactly what :&& does: *:&&* [&] Must be the first one: Keep the flags from the previous substitute command. Examples: > :&&...

View answer
Plugin help files not found
Accepted answer
9 votes

you have to create the help-tags. Run :helptags for the dir where you installed the docs. On unix this would most likely be :helptags ~/.vim/doc. Or simply recreate them all with :helptags ALL

View answer
source the current file
Accepted answer
9 votes

:so % % refers the current buffer's filename. This works not just for :source, but for all of the commandline; see :help cmdline-special.

View answer
Delete to next search result?
Accepted answer
7 votes

this can be done with d/term<cr>

View answer
Is possible in vim to delete a line after a word or character?
Accepted answer
6 votes

you can do this with :g/regexp/+d In your case this would (probably) be :g/\.\.\./+d This (internally) marks all lines matching the regexp and then deletes the next line

View answer
I've just installed (g)Vim, how do I get arrow keys to access command history?
Accepted answer
6 votes

Without a .vimrc vim will run in cp-mode (compatibility-mode). Just create a .vimrc in your home-dir and the problem should be fixed. The .vimrc can be empty, though it is advisable to put set nocp in ...

View answer
E129 when calling the function by call()
Accepted answer
6 votes

the confusing part here is that call is a command and call() is a function. After : you cannot simply write foo(). You have to write a (ex-) command calling foo(), like in call foo() or echo foo()...

View answer
Sharing the config file for vim and gvim
6 votes

Vim reads ~/.vimrc; gvim reads ~/.gvimrc as well as ~/.vimrc. So simply put your commands into ~/.vimrc (and put the GUI-specific commands into ~/.gvimrc). Newer Vims also look at ~/.vim/vimrc and ~/...

View answer
Where is the command list for the default keys?
Accepted answer
5 votes

you find a complete list under :help normal-index There is also a insert-index, visual-index and ex-edit-index

View answer
How to highlight/match (but not search!) the word under cursor
5 votes

I use the mark.vim-plugin for this. It can handle many interesting words at the same time and allows to jump between highlighted words.

View answer
How to trigger <tab> auto completion in a key mapping?
Accepted answer
5 votes

you can use :nnoremap <leader>e :call feedkeys(':e<space><tab>','t')<cr> the t indicates to use the keys as typed (as opposed to coming from a mapping)

View answer
Keeping context while scrolling
Accepted answer
5 votes

I would simply use :rightbelow split.

View answer
What filters are available?
4 votes

consider every program that reads stdin and writes stdout a filter. What is available is out of scope of vim. It largely depends on your OS and installation. The sort of the example in the vim-docu is ...

View answer
Backspace over newline
4 votes

this is controlled by the backspace option. You want :set bs=eol

View answer
Removing trailing spaces with the substitute command changes the cursor position
4 votes

Save the position and restore it again, as in: function TrimWhiteSpace() let save_cursor = getcurpos() %s/\s\+$//e call setpos('.', save_cursor) endfunction

View answer
file name completion in .gitignore
3 votes

how do you trigger file-name completion. completing with ^X^F should do it if '!' does not show up in set isfname?

View answer
Add prefix to numbers at beginning of each line
3 votes

You can do this with :%s/^\ze\d/3. From :h /\ze \ze Matches at any position, and sets the end of the match there: The previous char is the last char of the whole match. |/zero-width| Can be ...

View answer
How to write the output of scriptnames into a file?
Accepted answer
3 votes

this can be done with redir >names.txt|silent scriptnames|redir END I'm using silent here to avoid a -- more -- -prompt.

View answer
How to transfer a register to the system clipboard?
Accepted answer
3 votes

you can try :let @*=@a to assign register a to register *. Same for @+ (depending on which clipboard you want)

View answer
:put at the end of the current line?
Accepted answer
3 votes

Why stick to put? There is a nice alternative to it, like : i#Meeting Name - ^R=strftime("%F")<cr> btw: Your example seems to be missing a <cr> after the )

View answer
Finding all semicolons not preceded by backslash
Accepted answer
3 votes

this regex should match what you want /\(^\|[^\\]\)\zs;/ Broken down: /\(^\|[^\\]\)\zs;/ 122222222222233345 aabccdeeefgg 1 : / start the search 2 : \(...\) group what to match first (...

View answer
How can I visually select a regex match?
3 votes

This can be achieved with gn. See :h gn for details.

View answer
Can I change the command mode (: ...) so that I can have vi shortcuts?
Accepted answer
3 votes

you can press ctrl-f after : to get access to the commands (same for /) or you can enter cmd-mode with q:

View answer
How to identify the highlight groups in use on a particular character?
Accepted answer
3 votes

from my .vimrc (all in one line): nnoremap <M-i> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") ."> lo<" ...

View answer
How to remove every second column in Vim?
Accepted answer
3 votes

this is doable with :s, as in :%s/\("[^"]*"\)\s*,\s*"[^"]*"/\1/g

View answer
How to use regular expressions with \w\d inside ()
Accepted answer
3 votes

\w does not represent a word but merely a word-character. You want :%s/\(\w\+\)\(.*\)/\1/g Also, in this simple example the /g does nothing though

View answer
Syntax of keys on keyboard in documentation
2 votes

:help key-notation shows a complete list of all special keys.

View answer
May I have a Vim session report its "Mode" in its "Window Title"?
Accepted answer
2 votes

You can try :set titlestring=%F\ %{v:servername}\ %{mode()} this will indicate the mode as n rsp. i and some other characters as described in :help mode() You can improve the last expression (%{...

View answer
How to combine 2 actions for different mode into one mapping
Accepted answer
2 votes

you cannot use nnoremap here. Use nmap instead. This is because B is a mapping that NERDtree provides and nore means to not use an existing mapping.

View answer
What does `-` mean in command `ls -la | vim -`?
Accepted answer
2 votes

from help -- : Start editing a new buffer, which is filled with text that is read from stdin. ls | vim doesn't work, because vim reads it's commands from the terminal (as opposed to the content of a ...

View answer