Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
For example, when I'm entering a long command and I want to delete the second word, I want to be able to type <Esc> b b dw.
You can use set -o vi to use Vim-like shorcuts.
To make this permanent, you'll want to put this in your shell's rc file (e.g. for bash, put set -o vi in ~/.bashrc).
You should then log out and log back in, or just use $ source ~/.bashrc.
The best strategy depends on your experience with the command line.
I learned and got used to the default emacs-like mappings used in bash way before I started to learn Vim. They are too ingrained in my fingers for me to even consider enabling "vi mode". If you have more experience with bash than with Vim, I'd say that "vi mode" won't help you much. If, on the other hand, you have more Vim experience or are starting out with both, you may like the familiarity of "vi mode".
For what it's worth, I actually believe that "vi mode" is very close to useless. When on the command line, you are inserting text and Vi[m] is not better than others on that front. When you want to edit a command, "vi mode", with all its geeky shine, can't be compared with the power of a proper editor.
<C-x><C-e> provides the best editing experience you could ever dream of so why bother with the limited "vi mode"?
Try fc and fc -l for even more goodness.
Related
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I usually use 'less' to browse log files. But, sometimes, I need to use vim for its superior navigation facilities. But, the larger the log files, the longer it takes for vim to load them. 'less' seems to load them almost instantly.
Opening in read-only mode using 'vim -R' doesn't help.
Are there any other options using which I can open large files with vim quickly?
Please let me know if any other information is needed.
Try starting vim without plugins:
vim -u NONE
You might also want to consider other options outlined here.
Alternatively, consider removing portions of log files before opening up in an editor. Try using ack instead of grep. The -Q option makes ack treat the pattern as a literal and should be considerably faster (similar to grep -F).
awk -Q pattern huge-file | vim -
Prefixing the above command with LANG=C might help if you're using UTF-8 locale.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm an absolute beginner and I've never worked on a Linux machine before. I was working on a emacs file from home on a virtual machine. Now that I'm on a Linux machine at school, how do I run LateX on the file and view the dvi? I was able to open emacs and load the file.
You can use C-c C-c, which is bound to the function tex-compile.
Here's a useful hint: you can use C-h m to bring up the documentation for a mode. This documentation usually has a list of the keybindings associated with the mode. In this case, there's a list under the heading "Special Commands:" which includes C-c C-c tex-compile as well as some other commands which may be useful in the future.
One of the best things about Emacs is that it's self-documenting, so learning to use the help system (keys starting with C-h) is invaluable.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I just installed GVIM, went through the menus, and changed a bunch of settings.
I closed GVIM, and the settings were all lost. :(
I made my changes again.
Now how do I keep my settings?
You can use :set command to list all settings and put it to ${HOME}/.vimrc.
:se[t] Show all options that differ from their default value.
I wonder why nobody mentioned to use a vim session to save global settings and the views for all windows. Of course mastering .vimrc should be on the agenda of any serious vim user, but sessions can help further. Especially since they are similar to 'profiles' which are familiar to many people.
There also exist a plugin for gvim that facilitates the dealing with sessions further (sessions.vim : Easy session management for gvim.
You should really learn how to use .vimrc. Like VIM itself, learning to do this the hard way means more power and ease of use later.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm looking for a tool that will tell me what my keyboard is sending to the operating system when i push different keys.
This is to help me answer this question How to get Cmd-left/right working with iTerm2 and Vim (without requiring .vimrc changes)? which has me trying to figure out why Vim treats my iTerm2 mapping of Cmd-left to Escape-[H differently from Home.
I tried unix's read, and it says that Home and Cmd-left both produce "^[[H". I'm hoping that read is misleading me, and that some other tool will show how Home and Cmd-left are different (note: when I say, Cmd-left in this paragraph, it is when iTerm2's mapping is turned on).
Thanks!
You're doing all this in a terminal, right?
I'm afraid you're not going to do much better than read (my preferred approach is to do cat > file, type, press ^D, and then look at the file in a hex editor).
With regard to the underlying question, it's worth hunting for options in your terminal emulator. Right now it's emulating a terminal which doesn't distinguish between HOME and CMD+LEFT. It may be possible to tell it to emulate a different terminal, which does.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Is there a way to prevent a command from being added to the bash shell's command history?
I would like to be able to prevent certain "dangerous" commands from being added to the history, such as "rm -rf ~/some/dir", so that it is not accessible to me by pressing the up-arrow to reach previous commands. In this way, it would not be possible to accidentally repeat one of these commands.
The reason I ask is that I use the up arrow a lot to access previous commands in the shell history, and have often caught myself about to hit enter on what I thought was the correct command, only to realise that I was about to do something stupid/annoying/dangerous. I don't like the idea of rms etc floating around in my shell history, waiting for me to step on them!
(Note: I am aware that one can set up patterns in HISTIGNORE, but what would be nice is something one can apply on a per-command basis, which would become good a habit. Unless there is a clever way to achieve this using HISTIGNORE that I have missed?)
On newer Bash Versions you could simply add a space at the beginning of your command. :)
If it doesn't work by default, add [ \t]* to HISTIGNORE. (As mentioned in the comments. thx)
Add ignorespace to your HISTCONTROL environment variable. Then any command line that begins with a space won't be entered into your history.