Is there a weak visual indicator of all the texts that match the current selection? Similar to most text editors.
How I can achieve the same behavior?
You can certainly build something like that, using an :autocmd that obtains the current selection, and then either using default search highlighting (by modifying register /), or using matchadd() to add separate highlighting (but in contrast to search, that would be window-local by default). To make this robust and non-interfering with common tasks in Vim, that would be much more than a simple one-liner I could post here, though.
I must know, because I've implemented such as part of my SearchHighlighting plugin. With that plugin, this can be enabled via
:SearchAutoHighlighting selection
Because my plugin contains that functionality only as a small part (of more comprehensive search tweaks and additions), also have a look at the following alternatives, which are more targeted to what you're asking for, taken from the alternatives list of my plugin:
highlight_word_under_cursor.vim implements the search
auto-highlighting of the whole and optionally current word.
HiCursorWords highlights the word under the cursor, with
optional delay and limited to certain syntax groups.
Matchmaker highlights the word
under the cursor with matchadd(), not the current search pattern.
vim-cursorword automatically underlines the current word
in the current window (like :SearchAutoHighlighting), but uses :match
instead of search
Related
I frequently use the combination c-a-w to change a word in Vim.
Are there any similar means by which one can quickly also change all other occurrences of said word in the specific file?
Use gn option for this purpose, in my case, I have a slightly different version of it
" allows me to use a smarter cgn
nnoremap c* *<c-o>cgn
nnoremap c# #<C-o>cgn
Now when you have to change a word many times, as long as you have not so many of it, because in this case, a classical substitution would be better, just press c* and then press "dot --> ." to change the next occurrencies of it.
If you want to see how awesomeness gn can give us have a look at: Operating on search matches using gn (vimcasts)
You could try:
%s/<CTRL-R><CTRL-W>/NewWord/g
<CTRL-R><CTRL-W> means keep control key pressed and hit R and W.
This copies the word under the cursor to the command line.
See :help c_CTRL-R_CTRL-W.
The main command for replacement of all occurrences is :substitute. Unfortunately, being an Ex command, it doesn't integrate too well with the single-word replacement (e.g. caw) in normal mode: Though you can insert the previously replaced word into the command-line with <C-R>", you still have to enclose it in \<...\> to enforce a whole word match, and also escape any special characters inside the word.
That said, there are plugins that offer help in that area. One of them is my ChangeGlobally plugin, which offers a gc{motion} alternative to c{motion} that then applies the change (or deletion) to other matches in the same line or entire buffer. (The plugin page has links to alternative plugins.)
Is it possible with Vim itself or a plugin to display the autocomplete option inline?
If not is there a way to display text in vim without inserting it into the buffer?
You can disable the popup menu (:help popupmenu-completion; it usually displays [a subset of] the available choices) by removing menu[one] from the 'completeopt' option. Then, the first candidate (or longest common part) is directly inserted into the buffer, and <C-n> cycles through candidates at that location. To remove the current suggested completion and return to the original state before the completion, press <C-e>.
That technically still (if only temporarily) inserts the candidate into the buffer, but I think it closely fits what you're asking for, and is built-in. To display text without inserting, there's currently only a (rather crude) workaround of using the :help conceal feature to change the appearance of individual characters (for a static text, matching the exact location in the buffer via \%l and \%c) into something else via matchadd(). However, this only works if there's existing text; it wouldn't work at the end of a line. Currently, a generic overlay feature is being discussed on the the vim_dev mailing list, but it is in very early stages.
By default, supertab is inserting a regular tab when the previous character is a space.
I would like to keep this behaviour but with the following exception: if the previous character is a space but the preceding word is import, autocomplete.
For instance (| denotes the cursor position)
from numpy import |<tab> should display completions,
for |<tab> should insert a tab.
I'm aware of g:SuperTabNoCompleteAfter but I'm not sure how to obtain the desired result.
supertab has the ability to consider the preceding text to choose a completion type. You need to teach the plugin about the import context, and configure it to use a custom completion, e.g. user completion (<C-x><C-u>). Then implement the corresponding completion (or find another plugin that already does this), and you should be good.
References
context completion at :help supertab-defaultcompletion
completion contexts at :help supertab-completioncontexts
Writing a custom completion at :help complete-functions.
How to write complex syntax parser in flex/bison and connect it as vim plugin ?
Need some generic way to make vim colorer (and completion in ideal case) plugins using flex/bison -- especially for some complex languages, can't be covered by dumb vim regexps.
The same method should be used for Eclipse-like "outline" tab -- parse source and make clickable side panel for fast source navigation.
PS: win32 (mingw) .dll preferrably for this build: http://www.vim.org/download.php#pc
So, you want to do the actual parsing of a Vim buffer outside of Vim, by your flex/bison-based parser, and then perform the highlighting within Vim based on that parsing, right?
Well, inside Vim, the highlighting is based on regular expressions (given to the :syntax match or :syntax region commands). There's no way around that (short of extending Vim itself).
The only way that I see is using line / column addressing for parsed elements. Vim regular expression have special atoms that only match at a particular position (:help /\%l, :help /\%v).
In Vim 8, you could trigger your parser (asynchronously in the background) via the new :help channel feature.
Example
Your parser has identified an identifier at line 3, screen columns 14-16. You would synthesize the following Vim command:
:syntax match Identifier "\%3l\%>13v\%<17v."
Critique
This will work for static buffer contents. As soon as you're doing edits, highlighting will probably be trailing behind. Vim applies the regexp-based highlighting as you type, but your external parsing will add some more delay.
For complex syntaxes / large buffers, the number of distinct syntax elements may cause performance degradation within Vim. I'm not sure how efficient the regexp-based addressing is; this would need to be tested.
Vim newbie here.
I would like to be able to create tabs in Vim such that, for example, the tabs are at 4" left and 1.5" right for one type of section, 1.5"/1.5" for another, etc.
I know how to set tab stops, etc. but the trick here is I would like vim to recognize key combinations like shift-enter to go to one kind of formatting, plain enter to go to another kind, etc.
Is this even possible with vim?
TIA
I think you're confusing Vim with a word processor (like Word or Writer). There's no measurement in inches, no left / right margins, etc.
Vim's 'tabstop' option is a multiple of the width of a single space character that a <Tab> character (ASCII 0x09) expands to. This is fixed for the entire buffer (though you could use a set of :autocmds to change it in different parts of a buffer). Vim has no notion of paragraph text styles like a word processor, where you can define different styles. Vim only has a rather primitive :hardcopy command for printing.
If you need elaborate text formatting capabilities, Vim probably is the wrong tool, except if you choose to edit a source code document (like Latex, HTML, or Markdown), which is only compiled into a document (for those, like editing programming languages, it's actually well suited and powerful).
The vimtutor command (see :help vimtutor inside Vim) provides a good introduction to Vim's capabilities.
Check out these screenplay scripts. At least the first one contains custom tab widths as required in the traditional play formats. Perhaps they provide you the right idea on what's possible with Vim:
http://www.vim.org/scripts/script.php?script_id=2447 by Mike Zazaian
http://www.vim.org/scripts/script.php?script_id=1842 by Alex Lance