New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Ctrl-t default behavior #160

Closed
sdhull opened this Issue Mar 15, 2012 · 9 comments

Comments

Projects
None yet
7 participants
@sdhull
Copy link

sdhull commented Mar 15, 2012

In my workflow, I like to keep tabs open of files I'm working on. This means when I want to open a new file, I almost always want it to open in a new tab. When I have too many tabs open, I love the functionality of switching back to a tab for a file I already have open. So ctrl-t is now my favorite way to open files with Ctrl-P, but it feels awkward.

Is there any way to make Ctrl-t the default behavior when I just want to open files with "return"?

@kien

This comment has been minimized.

Copy link
Owner

kien commented Mar 15, 2012

You can just remap the keys.

This is the default:

    \ 'AcceptSelection("e")': ['<cr>', '<2-LeftMouse>'],
    \ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
    \ 'AcceptSelection("t")': ['<c-t>'],
    \ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],

Just switch <c-t> and <cr> and you're done:

let g:ctrlp_prompt_mappings = {
    \ 'AcceptSelection("e")': ['<c-t>'],
    \ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
    \ }

@kien kien closed this Mar 15, 2012

@sdhull

This comment has been minimized.

Copy link

sdhull commented Mar 15, 2012

Awesome. Thanks @kien! :)

@daGrevis

This comment has been minimized.

Copy link

daGrevis commented Feb 20, 2013

Thanks!

ealden added a commit to ealden/dotvim that referenced this issue Oct 5, 2014

@jlgasparrini

This comment has been minimized.

Copy link

jlgasparrini commented Oct 6, 2015

Good Joob!! 👍

@jlgasparrini

This comment has been minimized.

Copy link

jlgasparrini commented Oct 6, 2015

For this behaviour! When we seek and open the first file with ctrl-p, Is there any way (with default settings) to remove the empty tab? (This empty tab is created by vim, when this is opened)
a little clearer

@sivaswami

This comment has been minimized.

Copy link

sivaswami commented Oct 7, 2015

❤️ this option

@runekaagaard

This comment has been minimized.

Copy link

runekaagaard commented Oct 16, 2015

The remapping don't seem to work with nerdtree. When nerdtree is open while I press enter in ctrlp it replaces nerdtree instead of creating a new tab. It works fine with ctrl+t.

@runekaagaard

This comment has been minimized.

Copy link

runekaagaard commented Oct 17, 2015

I made it work with nerdtree and the powerline tabline by adding this to my .vimrc:

let g:ctrlp_open_func = { 'files': 'CustomOpenFunc' }
function! CustomOpenFunc(action, line)
    call call('ctrlp#acceptfile', [':t', a:line])
endfunction
@acidjazz

This comment has been minimized.

Copy link

acidjazz commented Aug 26, 2016

@kien I think this is definitely something that should be in the readme, everyone has their preference of how they open files and I think this really helps w/ that, if you want I'll write it up and submit a PR if you don't have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment