Reputation: 93
Personally, I am frustrated at most to use vim to edit simple files.
I am following this tutorial to set up Ubuntu on an VPS server which requires the deletion of some lines in ~/.vnc/xstartup file.
Could anyone recommend a better way to deal with this kind of problem, or just ditch vim altogether and use ftp?
Upvotes: 0
Views: 1174
Reputation: 217
Go through vim docs.
Also, you need to be in insert mode
to be able to insert stuff in the file
you can enter insert mode by presseing i
after opening a file.
Here is a more simpler guide.
Upvotes: 3
Reputation: 3179
tl;dr Move to the line to be deleted using either h/j/k/l or arrow keys and press the key d twice. Now save and exit with :wq.
I strongly suggest you learn the basics of vim, by simply using the vimtutor
command from your terminal emulator(if available in windows) or look up the vim-wiki. It's hard at first. But once you get the feel of it, there's no going back.
Most of the commands are based on mnemonics :
There are also three main modes of operations in vim that you should know about.
So here in your case, you want to delete certain lines from the file. First thing go into normal mode by pressing the Esc key and then move to the line you want to delete using the movement keys mentioned above. Then in normal mode press the d twice, that is dd. That deletes your line.
As a final step to save it go into command line mode using the : key. Now look at the bottom of your screen and you can see a ":". No type in wqa to write changes made to all buffers and quit.
Upvotes: 1
Reputation: 170
It takes a while to get used to vim, but once you do it is pretty fast; here are some useful commands
h
- left
j
- down
k
- up
l
- right
i
- go to insert mode to insert text like normally, you can also use normal shortcuts like ctrl-c
and ctrl-v
here
finally - if you want to save files, make sure you press esc
to go to "normal mode" (the default vim mode where you can use j to go down etc). If you want to quite and save your file type :wq
, if you don't want to save your file and quit type :q!
Once you get used to vim it is much faster than a normal editor - I also found it fraustrating at first. If you want to learn more about vim you can also type vimtutor
in the terminal (at least in mac) and it will give you a helpful tutorial
Upvotes: 2