Map Keys in QtCreator's Fakevim - qt-creator

I'd like to know how it is possible to use
:map
in fakevim (qt),
and how to load a .vimrc file.
Is it possible?

Yes you can use :map in Qt Creator's fakevim mode, but I'd discourage you to load your real vim's .vimrc file, because the fake vim mode is pretty minimalist. You can mostly use :set and :map, but forget about advanced vim specific stuff or plugins.
You can enable reading of a fakevim's vimrc by setting the option in:
Tools > Options > FakeVim category > General tab
there you can check:
Read .vimrc from location:
and specify the location in the text box next to it.

Related

Ctrl-P doesn't work on vi mode of command line editing on mac terminal

https://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html
said we could do set -o vi to use vi mode instead of emacs mode for command line editing.
And the help: ex-edit-index sais
c_CTRL-P CTRL-P after using 'wildchar' with multiple matches:
go to previous match, otherwise: recall older
command-line from history.
However when I press CTRL-P I just got ^P
May I know why ?
Readline's "vi mode" is neither vi nor Vim. It is a partial emulation of vi shoehorned into the command line context.
That <C-p> you are referring to is a Vim command so there is no reason whatsoever to expect it to do anything in that context. Vim's documentation is totally irrelevant in this case.
Search for Vim Mode bindings in $ man readline for the actual bindings at your disposal in that "mode".

Globally Map "Escape Key" to "jj" in vim (mac)

I have been using vim for awhile but I have not been able to figure out how to map the escape globally - every time I open a file, I have to map the escape key to jj like this:
:imap jj <Esc>
Is there a way to change the runtime defaults so that Esc is already mapped to jj?
I found the default.vim file, but you cannot edit it on a mac (with standard mac software). Should I download something to edit this file? Is there another easier way?
Any help is much appreciated!
The place for your local changes is called .vimrc and you typically create one in your home directory with the commands you want to execute on startup.
Run vimtutor on the (system) command line and spend a few minutes learning how to use this editor. Then dig into the facilities provided by :help in Vim. E.g. run :help vimrc in Vim.

Bash's vim mode, not vi

I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?
I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)?
If you set EDITOR variable, in bash you can press Ctrl-x ctrl-e to edit your current command line in your EDITOR e.g. vim
EDIT
the ctrl-x ctrl-e is for emacs mode commandline editing, which is the default one. If you have already set it to vi mode, you could do what you have said, pressing the v. If you want to open the cmd line in vim, you have to set the EDITOR variable (in your .bashrc for example)
Personally I edit command line in emacs mode, even though vim is my main (and only) editor.
In your .bashrc, put the following line:
export VISUAL=/usr/bin/vim
If you want vim in many other contexts too, such as in git, you should also set EDITOR:
export EDITOR=/usr/bin/vim

How can I debug issues in VimL?

I'd like to know more about debugging in vim. What features does vim have that can help me to diagnose a problem I might have?
I'd basically like to know:
How can I diagnose a problem with my .vimrc and other configuration files?
What are some strategies to debugging a script in VimL?
How can I diagnose a problem with .vimrc and other configuration files?
If you're having some unexpected behavior in vim and you're not sure where the
problem is originating, there are a few approaches to honing in on the source
of the issue. One of the best first steps is to find out if your problem is
normal vim behavior, caused by a plugin or caused by your .vimrc.
If your vim instance is setting a particular 'option' and you're not sure
where it is being set. You can use the :verbose command to find out. For
instance
:verbose set nocompatible?
nocompatible
Last set from ~/.vimrc
To run an instance of vim without any plugins or configuration files run
vim -N -u NONE
I set this as to alias called cleanvim in my .bashrc file. The -u NONE is
what's doing the magic here. The -N simply puts vim into nocompatible mode,
which generally is desired. You can also use the option NORC to only exclude
your vimrc. Note that if you use something like pathogen or vundle to
instantiate your plugins from within your vimrc, then your plugins will also
not load properly.
If you are using a plugin manager like pathogen or vundle then excluding your
plugins is simple; just comment out the line in your .vimrc that calls
pathogen or vundle. However if you have other plugins loaded from your .vim
directory you can exclude them with the --noplugin flag.
If your problem is being caused by a plugin, try adding back plugins one by one
to determine which one is causing the issue. From there you can either report
the bug to the plugin's maintainer or try to diagnose the problem yourself
using the tips from the rest of this answer.
If your problem is caused by your .vimrc there are some ways to hone in on
the problem further. Once simple method is to add the finish command at some
point in your .vimrc. Once this command is encountered the script will stop
being sourced and no commands after it will be executed. In this way you can
exclude large portions of your .vimrc and try to find out the general region
where the problem is coming from.
What are some strategies to debugging a script in VimL?
Vim has a help section on this topic at :h debug-scripts. This describes
vim's debug mode in detail, which will allow you to set breakpoints and step
through a sourced file or user function. You can add a breakpoint on a specific
function or a specific line in a file. For instance...
" set a breakpoint on the function MyCoolFunc
:breakadd func MyCoolFunc
" set a breakpoint on line 43 of your .vimrc
:breakadd file 43 .vimrc
" set a breakpoint at this location
:breakadd here
After you set a breakpoint you can source the file again to begin debug mode at
that line. If you'd like to use debug mode on an entire file start vim with the
-D flag. You could also run debug mode on a particular command. For example,
say you're having trouble with a particular command :MyCommand. You can start
debugging mode on this command with :debug MyCommand.
Once debug mode has been started you can use the usual set of vim commands.
This is useful because you can now check the value of variables using the
echo command to try and diagnose an issue. You can also use the verbose
option to provide extra information about the following lines. See :h 'verbose'
for its options.
The scriptease is very helpful to debug vimL:
provide commands for easier insertion of Vim breakpoints
:Runtime allows easy reload of plugins, even unleting include guards
:Disarm {file}: attempt to disable a runtime file by removing its mappings, commands and autocmds
:Time {command}: profilling
:Verbose {command}: like :verbose, but capture the results to a file and load it in the preview window
For cases where you need to restart Vim several times (e.g.: incremental removal of plugins) the :RestartVim command of session plugin can be useful.
For vimL I find those 2 plugins awesome:
BreakPts
Set/View Vim breakpoints and browse functions visually
Decho
Better echo functionality suitable for debugging scripts
I also use this to quickly source the selected vimL lines:
fu! SourceRange() range
let tmpsofile = tempname()
call writefile(getline(a:firstline, a:lastline), l:tmpsofile)
execute "source " . l:tmpsofile
call delete(l:tmpsofile)
let n = a:lastline - a:firstline + 1
echo 'Sourced ' . n . ' line' . (n > 1 ? 's' : '')
endf
com! -range Source <line1>,<line2>call SourceRange()
nn gs m`:Source<cr>``
vn gs m`:Source<cr>``

How can I activate Vim color schemes in OS X's Terminal?

I'm working with the Vim 7.2 that comes with Mac OS 10.6.1 (Leopard), using the Mac's "Terminal" app. I'd like to use a fancy color scheme. I did this...
:syntax on
Then this...
:colorscheme slate
:colorscheme elflord
:colorscheme desert
etc...
Syntax highlighting is working, but I'm finding that regardless of the scheme I choose, the only colors displayed are the basic Red, Blue, Cyan, Gray, etc.
Is there a way to get the Terminal app to display a larger collection of colors to allow some more subtle schemes?
Create a .vimrc file on your home ~/ folder and then edit it with vim ~/.vimrc. You can try adding syntax on inside ~/.vimrc file. The following command does that:
echo "syntax on" >> ~/.vimrc
It will highlight your code syntax on vim
You need to create file ~/.vimrc and add syntax on in that file
vi ~/.vimrc
syntax on
save the file
and run your vim
Add "syntax on" to the file /usr/share/vim/vimrc and you'll get highlighting in your files every time you edit one.
# vi /usr/share/vim/vimrc
Add this line at the end of the file:
syntax on
Now you'll get highlighting when you edit whatever's file.
The Terminal.app supports AFAIK only 16 colors; iTerm supports more colors or you use mvim (as suggested by Daniel).
You might want to consider using a version of Vim that is a native Mac app (that runs in a window).
MacVim has great color schemes and you can still launch it from Terminal like so:
$ mvim file.txt
That will open your file in a new Vim window.
#ashcatch - Can't leave a comment, but wanted to add that iTerm has other advantages over Terminal.app such as sensible copy and paste (configurable 'word' regex for easy double click selection of paths/urls, middle click paste) and terminal mouse support (:se mouse=a in vi to get mouse text selection, moving of window borders etc.)
I'd be lost without it.

Resources