Hot answers tagged

239

If you don't already have a .vimrc file in your home directory, create one using this: vim ~/.vimrc Add this line to the top of the file: set nocompatible Save the file and this should fix the problem for you. :)


200

First, make sure you're in edit mode (press i). Then you can paste with Ctrl+Shift+V, if you're in a terminal emulator like gnome-terminal (or select "Paste" from the right-click menu). You can also type :set paste in vim before you paste to disable automated indenting, etc. Then :set nopaste after you've pasted the content. Also check this question on ...


142

You can use process substitution (this also works with applications that can't read from STDIN): vim <(ls -la) Or use vim's function to read from STDIN: ls -la | vim -


119

Resolved it : /etc/vim/vimrc Already contains necessary feature. Just need to uncomment it: " Uncomment the following to have Vim jump to the last position when " reopening a file if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif (Infact, you can refer to /usr/share/vim/...


98

Installing the vim package will fix the problem: sudo apt-get install vim There are many good vim/vi tutorials on YouTube, or the web generally. For your problem, see the article 8 Essential Vim Editor Navigation Fundamentals. Then continue to open files as usual: vi desired-file


79

Try from within vim ... :version and if your get ... Small version without GUI. You are missing package vim-gui-common. It is probably also advisable to install vim-runtime. Commands to install: sudo apt-get install vim-gui-common sudo apt-get install vim-runtime Another cause might be that alternatives is pointing to the wrong one: update-...


74

Here is the simplest solution. Open a terminal, go to home directory and type vi .vimrc a new file open now add these lines to the file and exit by saving $ set nocompatible $ set backspace=2


67

I had this same problem and it turned out that the .viminfo file in my home directory had the wrong ownership. It was owned by root:root. Once I fixed the file ownership by changing it to myself, remembering file position started working for me again


67

Vi (and Vim) works very differently compared to a normal text editor such as Gedit. It also has a pretty steep learning curve. If you want to learn some basic commands, start with this interactive tutorial. However, to answer you question. The system clipboard's content can be accessed through the plus register. So to paste something from the system ...


59

Wikipedia has a concise and properly cited explanation: The name vi is derived from the shortest unambiguous abbreviation for the command visual in ex; the command in question switches the line editor ex to visual mode. http://en.wikipedia.org/wiki/Vi Note that this does not mean that the full name of the text editor "vi" is still "visual" or, even, ...


49

I suggest you install vim. From the terminal Ctrl+Alt+t: sudo apt-get update sudo apt-get install vim Several dependencies will also be installed. Then start a new project, again from the terminal: vim new_project.c Learn more about vim: man vim


39

That's correct behavior for vi, and it does erase the character, it just doesn't show it by replacing it with a blank like in vim. It will be apparent when you overwrite the erased character with another character, or switch back to command mode. E.g. starting with command mode on an empty line, the following will result in the line containing fo: ...


38

You're really close on your own. You were just missing one character. ls -la | vim -


34

Writing a text file isn't going to "change the way that your computer functions". In particular, in order to do something like that, you'd have to do one of overwrite some important file write your file to a special protected location like a *.d directory in /etc; you won't have permission to do this mark the file executable and put it in your path Since ...


32

Inside the Ubuntu ecosystem, I do not think this case can even exist, as vi would at least be a vim-tiny, which is already a “real vim” far from “real vi.” In the context of resource limited embedded systems, which are not normally Ubuntu, you may just have a vi that turns out to be a link to busybox. And not space left. Then, vi is the only option. ...


30

If you want to copy paste contents within the same file, use yank and paste. If you want to copy paste contents across terminals, open the first file, yanking the text you want, then open your second file within vim (e.g. :tabnew /path/to/second/file) and press p to paste it. If you want to copy paste contents from vim to an external program, you need to ...


28

Type sudo apt-get install vim in your terminal, this will solve your problem


27

With vi, when clicking on i you activate the command to Insert text. This command allows you to insert text in your file. And right, when clicking : on ↑ it will insert a "A", on ↓ it will insert a "B", ... Till you deactivate this command. To deactivate a command in vi : just click on Esc And then you will get back normal use of your arrow keys: ↑ to go ...


27

After installing vim running vimtutor from the commandline you'll get "a 30 minute tutorial that teaches the most basic Vim functionality hands-on" as it calls itself.


24

You need to install the actual vi package, which is nvi on Ubuntu. sudo apt-get install nvi You might also need to run the line below if nvi isn't picked up automatically as the default provider for vi. sudo update-alternatives --config vi


24

Installing VIM will probably solve that issue sudo aptitude install vim it actually has to work though, it might be that compatibility mode is on therefore you will be in the insert mode but VI won't tell you. Either way using vim is recommended, its basically V i IM proved.


23

Ctrl+Q will undo Ctrl+S. These are ancient control codes to stop and resume output to a terminal. They can still be useful, for instance when you are tailf-ing a log file and something interesting scrolls by, but this era of unlimited scrollback buffers has really obsoleted them.


23

You need to change to the "insert" mode by moving the cursor with i. There are other ways to delete characters directly. You can download a powerpoint that I use when teaching a class on VI here. It sounds like you are in the "Command" mode. To move your cursor: H = Left, J = Up, K = Down, L = Right Once you have your cursor positioned you can delete ...


23

Vi is a screen editor for Linux, Unix and other Unix-like operating systems. Pronounced (vee-aye). Stands for VIsual. Sources: http://en.wikipedia.org/wiki/Vi and http://www.techopedia.com/definition/10347/vi


23

If you are looking for an alternative editor, you are not alone. Basically life is too short to learn vi and I say this being a software developer for a living. However you should learn how to exit it because it's a problem for one out of 20k programmers. Also performing some basic append/insert operation might be worth learning, because on some stubborn ...


20

Here's another approach, hopefully to teach someone something new. If you know that the command :r !ls -la works inside vim, you can do the following to open vim and make it run the command as soon as it opens, straight from bash: vim -c ':r! ls -la' This is the equivalent of opening vim then executing the command :r! ls -la. This should work with any vim ...


19

I always use Shift+Insert when I want to paste text into the terminal, works in all terminal programs. (Which is also the reason why I never get a laptop where you can't press Insert without pressing a secondary key)


Only top voted, non community-wiki answers of a minimum length are eligible