vi editor : Non-text symbols appear while reading [duplicate] - vim

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'

Related

Adjusting all line to Left side of the file in gvim [duplicate]

This question already has answers here:
Remove all arbitary spaces before a line in Vim
(9 answers)
Closed 5 years ago.
I'm new to the vim editor.
How can I adjust all lines to the left? I have many lines which are indented and I want to arrange them so they all abut the left side of the file (no spacing at the start of the lines).
Select all line in visual mode and then type :left . Hope this helped.
keerthan
The simple key sequence :%left will do the trick, it basically applies the left command to all lines in the file.

vim: Marks getting deleted/lost [duplicate]

This question already has answers here:
Make vim keep mark when I delete the line the mark is on
(2 answers)
Closed 6 years ago.
I've tried to find an answer to this on the googles, but been unsuccessful. The problem is this:
In vim I delete a line that contained a mark; so I guess the mark is also deleted. Now I can't jump back to that location any more. I'm coding so there is a lot of line deleting going on. It's a pain having to manually find the place that I set the mark again.
Is there a way around this? I want vim to jump to aprox the same location where the mark used to be. Either the same line number, or the closest guess.
You can try `. which is a position of the last change occurred in the current buffer. Then you can mark it again.

How to trace a word back to where it was declared across multiple files in vim? [duplicate]

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

How do I execute command similar to gg=G in Vim without going to the top of the file? [duplicate]

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).

help: multiline abbr in linux vi? [duplicate]

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.

Resources