This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Writing a vim function to insert a block of static text
How can i add multi line abbreviations in vi editor ?
I am using vi from ssh terminal.
if i type "head " the vi should replace "head" with 2 line sentence in the format
as shown below
MAINTENANCE HISTORY
DATE AUTHOR AND DETAILS
Thanks.
With vim you can do:
:iab head MAINTENANCE HISTORY<CR>DATE AUTHOR AND DETAILS
(Or use imap/inoremap instead of iab if you don't want to have to insert whitespace/punctuation before it activates)
No clue if this is possible in vi.
Related
This question already has answers here:
gvim What do the # symbols mean at the bottom left of the screen?
(2 answers)
Closed 7 years ago.
I am having problem while scrolling and reading a large file through vi or gvimeditor. In the middle of a file, I am seeing a continuous stream of symbols ^# in blue, like we see often in binary files. However, I don't see them with other editors (e.g. TexEdit in my OS X).
Is it a common problem and is there a way to get rid of this?
add this line to your .vimrc file:
set display=lastline
to understand what it does, do a :h 'display'
This question already has answers here:
Jump to function definition
(11 answers)
Closed 7 years ago.
When reading through a person's code, I may be looking through a program that comprises 10+ files. I would like the ability to search for where an object/struct/type def have been declared.
Does vim allow you to do this kind of search? If so how?
You can use the CTRL-] command to "Jump to the definition of the keyword under the cursor." (see :h ctrl-]).
For this to work, you will need to create a tags file, for example with a program like ctags. The manual has more on this, see :h tag.
Sounds like you could use lvim to grep a word across multiple files.
From the documentation :
to search for the words "house" or "home" in all .txt files in the
current directory, use:
:lvim /\<\(house\|home\)\>/gj *.txt
:lw
You can also integrate external programs, like grep or findstr into vim for faster searching, but those will depend on your OS: http://vim.wikia.com/wiki/Find_in_files_within_Vim#Using_external_programs_for_fast_searches
This question already has answers here:
Customising word separators in vi
(6 answers)
Closed 7 years ago.
How can I customize word definition in Vim? The default is a series of character like _,[a-zA-Z] are considered as word. I'd like to add some other chars to this definition.
You can redefine the iskeyword setting.
Read the VIM docs for it or see this woss article for an example.
This question already has answers here:
Indenting entire file in Vim without leaving current cursor location
(5 answers)
Closed 8 years ago.
How can I reformat the whole buffer in Vim, the same way as I am doing using gg=G keys, without going the the top (which is caused by the gg)?
You can mark the current position with m<letter> command and then go back with `<letter>.
mzgg=G`z
The referenced duplicate uses more effective variant of this approach using the fact that double backtick goes to the last cursor position so you don't actually need to mark the current position:
gg=G``
Or you can install a plugin for text object of entire buffer (e.g. https://github.com/kana/vim-textobj-entire) and then do
=ae
(or equivalent with another plugin).
This question already has an answer here:
emacs isearch lazy highlight for whole buffer
(1 answer)
Closed 8 years ago.
How to get highlighting from interactive regex search in emac to remain highlight until deactivated? For instance, with the text provided and running M-C-s (Regexp I-Search) with input 'file' will highlight the 3 'file' words in the text below.
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
Regexp I-Search %> file
But, once I start to edit the file the highlighting will disappear. I'd like to keep the highlighting for a while -- until I run another command to turn it off. How could I do this?
If you set the variable lazy-highlight-cleanup to nil, then the highlight remains until the next search:
(setq lazy-highlight-cleanup nil)
Or, until you manually call M-x lazy-highlight-cleanup.
You're looking for highlight-regexp bound to M-s h r. M-s h u unhighlights.
highlight-symbol provides a nice wrapper around this.