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

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.

Related

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

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'

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

Negative numeric argument in Vim [duplicate]

This question already has answers here:
Delete n lines in the up direction in vim
(5 answers)
Closed 9 years ago.
Is there a way to apply a vim command backward? For example, I want to kill 5 lines backward, instead of 5dd, is there something like -5dd?
From :he d:
["x]d{motion} Delete text that {motion} moves over [into
register
x]. See below for exceptions.
How about 5dk 4dk (k being the motion for upwards)?
Edit: changed count to 4 as this results in 5 lines being deleted apparently...

Using listchars to show leading whitespace in Vim [duplicate]

This question already has answers here:
Make Vim show ALL white spaces as a character
(23 answers)
Closed 9 years ago.
I use spaces over tabs. In Sublime Text 2, I would have leading spaces show like so:
I have my .vimrc setup to show tabs, line endings, etc. But I'm not sure how to replicate what I have in Sublime. It was handy as I could still see indentation much more easily when just using spaces.
Here's my line for it now:
set listchars=eol:¬,tab:→→,extends:>,precedes:<
The list+listchars combo can show trailing spaces but not leading spaces.
You could try vim-indent-guide.

Vim: Convert hard wrap to soft wrap [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Unwrap text in vim
How to convert hard wrap into soft wrap in a text file, using vim or (if simpler) some other standard GNU/Linux tool? And this while preserving paragraphs as such. It would be easy to remove all line breaks, but not serviceable.
By hard wrap I mean a document where each line ends at most at (for example) column 80.
I noticed that the program aquamacs has a function to do this, but I don't know what its output looks like, and it is Mac OS X only.
You can do this:
:%norm vipJ
It will unwrap all the paragraphs in you text. However, if you want to do it manually, simply do ipJ inside visual mode on each paragraph you want to unwrap.
I also found another way to achieve this
:g/^\s*\n.*\S$/+norm vipJ
which means:
:g "Execute command when pattern matches
Pattern:
^\s*\n "A line with only spaces or tabs (or none)
\n.*\S$ "A line with anything but ending with a non-space character
Command:
+norm vipJ "Join the lines in the paragraph
Please note that you'll need an empty line before the first paragraph too.

Resources