Archive for the ‘vi’ tag
Remove Windows line endings in VIM
The Windows line endings (^M) can be easily removed with most editors. In ViM it is very easy.
To remove all windows line endings (and replace with nothing), type the following:
:%s/^V^M//g
(note that the ^V will not display).
Sometimes it is necessary to add a line break as well:
:%s/^V^M/\r/g
Partly based on a Tech Recipes article.
Some useful Vim-commands
There are numerous pages and blog posts about Vi and Vim out there so here’s my small contribution. Here are some less frequently used commands that tends to be useful from time to time:
| Delete lines patching pattern |
:g/pattern/d |
| Go to position previously modified |
g; |
| Go to next modified position in change list |
g, |
| Create bookmark in file |
mLETTER |
| Go to bookmark |
'LETTER |
| Change highlighted text to upper case |
gU |
| Open file under cursor |
gf |
| Coopy text mathich pattern to register a |
:/pattern/yank A |
| Paste text from register a |
"ap |
| Reduce split window size |
C-w - |
| Increase split window size |
C-w + |
| Make split windows equally big |
C-w = |